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.

21 lines
700 B

  1. package common
  2. import (
  3. "encoding/hex"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestBJJFromStringWithChecksum(t *testing.T) {
  8. s := "21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d7"
  9. pk, err := BJJFromStringWithChecksum(s)
  10. assert.Nil(t, err)
  11. sBytes, err := hex.DecodeString(s)
  12. assert.Nil(t, err)
  13. assert.Equal(t, hex.EncodeToString(SwapEndianness(sBytes)), pk.Compress().String())
  14. // expected values computed with js implementation
  15. assert.Equal(t, "2492816973395423007340226948038371729989170225696553239457870892535792679622", pk.X.String())
  16. assert.Equal(t, "15238403086306505038849621710779816852318505119327426213168494964113886299863", pk.Y.String())
  17. }