You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
958 B

  1. package statedb
  2. import (
  3. "math/big"
  4. ethCommon "github.com/ethereum/go-ethereum/common"
  5. "github.com/hermeznetwork/hermez-node/common"
  6. "github.com/iden3/go-iden3-crypto/babyjub"
  7. "github.com/iden3/go-merkletree"
  8. )
  9. // TODO
  10. func (s *StateDB) getIdxByEthAddr(addr ethCommon.Address) common.Idx {
  11. return common.Idx(0)
  12. }
  13. // TODO
  14. func (s *StateDB) getIdxByBJJ(pk *babyjub.PublicKey) common.Idx {
  15. return common.Idx(0)
  16. }
  17. func siblingsToZKInputFormat(s []*merkletree.Hash) []*big.Int {
  18. b := make([]*big.Int, len(s))
  19. for i := 0; i < len(s); i++ {
  20. b[i] = s[i].BigInt()
  21. }
  22. return b
  23. }
  24. // BJJCompressedTo256BigInts returns a [256]*big.Int array with the bit
  25. // representation of the babyjub.PublicKeyComp
  26. func BJJCompressedTo256BigInts(pkComp babyjub.PublicKeyComp) [256]*big.Int {
  27. var r [256]*big.Int
  28. b := pkComp[:]
  29. for i := 0; i < 256; i++ {
  30. if b[i/8]&(1<<(i%8)) == 0 {
  31. r[i] = big.NewInt(0)
  32. } else {
  33. r[i] = big.NewInt(1)
  34. }
  35. }
  36. return r
  37. }