mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 03:26:39 +01:00
Poseidon & MiMC7 HashBytes remove return of err
This commit is contained in:
@@ -179,7 +179,7 @@ func Hash(arr []*big.Int) (*big.Int, error) {
|
||||
|
||||
// HashBytes hashes a msg byte slice by blocks of 31 bytes encoded as
|
||||
// little-endian
|
||||
func HashBytes(b []byte) (*big.Int, error) {
|
||||
func HashBytes(b []byte) *big.Int {
|
||||
n := 31
|
||||
bElems := make([]*big.Int, 0, len(b)/n+1)
|
||||
for i := 0; i < len(b)/n; i++ {
|
||||
@@ -193,5 +193,9 @@ func HashBytes(b []byte) (*big.Int, error) {
|
||||
utils.SetBigIntFromLEBytes(v, b[(len(b)/n)*n:])
|
||||
bElems = append(bElems, v)
|
||||
}
|
||||
return Hash(bElems)
|
||||
h, err := Hash(bElems)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
@@ -73,8 +73,7 @@ func TestPoseidon(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "2978613163687734485261639854325792381691890647104372645321246092227111432722", hmsg2.String())
|
||||
|
||||
hmsg2, err = HashBytes(msg2)
|
||||
assert.Nil(t, err)
|
||||
hmsg2 = HashBytes(msg2)
|
||||
assert.Equal(t, "2978613163687734485261639854325792381691890647104372645321246092227111432722", hmsg2.String())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user