Update and add test for PackSignY & UnpackSignY

- Update PackSignY & UnpackSignY interface and description
- Add test for UnpackSignY & PackPoint
This commit is contained in:
arnaucube
2020-12-21 16:53:02 +01:00
parent a0722b9e8f
commit 2318fd7044
3 changed files with 48 additions and 26 deletions

View File

@@ -218,6 +218,26 @@ func TestPointFromSignAndy(t *testing.T) {
assert.Equal(t, p.Y.String(), p2.Y.String())
}
func TestPackAndUnpackSignY(t *testing.T) {
x := utils.NewIntFromString(
"17777552123799933955779906779655732241715742912184938656739573121738514868268")
y := utils.NewIntFromString(
"2626589144620713026669568689430873010625803728049924121243784502389097019475")
p := &Point{X: x, Y: y}
pComp := p.Compress()
s, y := UnpackSignY(pComp)
pComp2 := PackSignY(s, y)
assert.Equal(t, pComp, pComp2)
emptyPointComp := [32]byte{}
s, y = UnpackSignY(emptyPointComp)
pComp2 = PackSignY(s, y)
assert.Equal(t, emptyPointComp, pComp2)
}
func TestCompressDecompress1(t *testing.T) {
x := utils.NewIntFromString(
"17777552123799933955779906779655732241715742912184938656739573121738514868268")