Skip to content

Commit

Permalink
add test for poseidon hash writer; rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-korotya committed May 23, 2023
1 parent 6ff38d4 commit 85b692c
Show file tree
Hide file tree
Showing 3 changed files with 363 additions and 5 deletions.
5 changes: 3 additions & 2 deletions babyjub/babyjub_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestBjjWrappedPrivateKey(t *testing.T) {
pub, ok := pk.Public().(*BjjWrappedPublicKey)
require.True(t, ok)

decomrpessSig, err := decomrpessSig(sig)
decomrpessSig, err := DecompressSig(sig)
require.NoError(t, err)

digestBI := big.NewInt(0).SetBytes(digest)
Expand All @@ -64,7 +64,8 @@ func TestBjjWrappedPublicKeyEqual(t *testing.T) {
require.False(t, x1.Equal(x2))
}

func decomrpessSig(commpresedSig []byte) (*Signature, error) {
// DecompressSig decompresses a compressed signature.
func DecompressSig(commpresedSig []byte) (*Signature, error) {
poseidonComSig := &SignatureComp{}
if err := poseidonComSig.UnmarshalText(commpresedSig); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions poseidon/poseidon_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ type digest struct {
frameSize int
}

// NewPoseidon returns the Poseidon hash of the input bytes.
// Sum returns the Poseidon hash of the input bytes.
// use frame size of 16 inputs by default
func NewPoseidon(b []byte) []byte {
func Sum(b []byte) []byte {
h, _ := New(16)
h.Write(b)
return h.Sum(nil)
Expand Down
Loading

0 comments on commit 85b692c

Please sign in to comment.