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.

33 lines
914 B

4 years ago
4 years ago
  1. package babyjub
  2. import (
  3. "github.com/dchest/blake512"
  4. )
  5. // Note on dchest/blake512: This specific blake512 module is compatible with
  6. // the version of Blake512 used at circomlib, and this module has been reviewed
  7. // to don't be doing do anything suspicious.
  8. // Blake512 performs the blake-512 hash over the buffer m. Note that this is
  9. // the original blake from the SHA3 competition and not the new blake2 version.
  10. func Blake512(m []byte) []byte {
  11. h := blake512.New()
  12. _, err := h.Write(m)
  13. if err != nil {
  14. panic(err)
  15. }
  16. return h.Sum(nil)
  17. }
  18. // DecompressSig decompresses a compressed signature.
  19. func DecompressSig(commpresedSig []byte) (*Signature, error) {
  20. poseidonComSig := &SignatureComp{}
  21. if err := poseidonComSig.UnmarshalText(commpresedSig); err != nil {
  22. return nil, err
  23. }
  24. poseidonDecSig, err := poseidonComSig.Decompress()
  25. if err != nil {
  26. return nil, err
  27. }
  28. return poseidonDecSig, nil
  29. }