diff --git a/internal_test.go b/internal_test.go index d33debc..f25c741 100644 --- a/internal_test.go +++ b/internal_test.go @@ -15,3 +15,18 @@ func HexToHash(h string) (result Hash) { copy(result[:], byteSlice) return } + +// RandomPubKey takes a random scalar, interprets it as a point on the curve +// and then multiplies by 8 to make it a point in the Group +func RandomPubKey() (result *Key) { + result = new(Key) + p3 := new(ExtendedGroupElement) + var p1 ProjectiveGroupElement + var p2 CompletedGroupElement + h := RandomScalar() + p1.FromBytes(h) + GeMul8(&p2, &p1) + p2.ToExtended(p3) + p3.ToBytes(result) + return +} diff --git a/ringct.go b/ringct.go index 2f53232..158ebbd 100644 --- a/ringct.go +++ b/ringct.go @@ -133,7 +133,7 @@ func AddKeys2(result, a, b, B *Key) { return } -// subtract two points together +// subtract two points A - B func SubKeys(diff, k1, k2 *Key) { a := k1.ToExtended() b := new(CachedGroupElement) diff --git a/ringsignature_test.go b/ringsignature_test.go index ead55f0..431b20d 100644 --- a/ringsignature_test.go +++ b/ringsignature_test.go @@ -1819,8 +1819,7 @@ func TestCreateSignature(t *testing.T) { privKey, _ := NewKeyPair() mixins := make([]Key, numMixins) for j := 0; j < numMixins; j++ { - _, pk := NewKeyPair() - mixins[j] = *pk + mixins[j] = *RandomPubKey() } keyImage, pubKeys, sig := CreateSignature(&hash, mixins, privKey) if !VerifySignature(&hash, &keyImage, pubKeys, sig) {