mirror of
https://github.com/luxfi/crypto.git
synced 2026-07-27 01:54:50 +00:00
The Banderwagon prime-order group used by Verkle / IPA had been vendored internally under lux/crypto/ipa/banderwagon. Extract it to lux/crypto/banderwagon as the canonical Lux public surface; rewrite all internal ipa callers (prover, verifier, config, multiproof, common, transcript, test_helper, tests) to import from the canonical home. - Provenance comment on every file: github.com/crate-crypto/go-ipa (Apache-2.0 / MIT dual). Adds LICENSE-GO-IPA-APACHE2 and LICENSE-GO-IPA-MIT alongside the package. - Element / Generator / Identity / Fr / MSMPrecomp / PrecompPoint / CompressedSize / UncompressedSize / SetBytes / SetBytesUncompressed / ElementsToBytes / BatchToBytesUncompressed / BatchNormalize / MapToScalarField / BatchMapToScalarField / Add / Sub / Double / Neg / ScalarMul / MultiExp now have one and only one home: lux/crypto/banderwagon. - Verkle (parallel branch) will switch its banderwagon import to this canonical surface. - KAT vectors from the upstream go-ipa Verkle reference suite preserved (TestEncodingFixedVectors, TestPointAtInfinityComponent) plus all precomp MSM-vs-gnark random-round tests (1000 * NumCPU rounds). Tests: go test ./banderwagon/... ./ipa/... — all PASS (banderwagon 27s, ipa 16s, ipa/bandersnatch 24s, fp/fr 4s+2s, common 3s).
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package test_helper
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"github.com/luxfi/crypto/banderwagon"
|
|
"github.com/luxfi/crypto/ipa/bandersnatch/fr"
|
|
)
|
|
|
|
func TestPoly256(polynomial ...uint64) []fr.Element {
|
|
n := len(polynomial)
|
|
if len(polynomial) > 256 {
|
|
panic("polynomial cannot exceed 256 coefficients")
|
|
}
|
|
polynomialFr := make([]fr.Element, 256)
|
|
for i := 0; i < n; i++ {
|
|
polynomialFr[i].SetUint64(polynomial[i])
|
|
}
|
|
|
|
pad := 256 - n
|
|
for i := n; i < pad; i++ {
|
|
polynomialFr[i] = fr.Zero()
|
|
}
|
|
|
|
return polynomialFr
|
|
}
|
|
|
|
func PointEqualHex(t *testing.T, point banderwagon.Element, expected string) {
|
|
point_bytes := point.Bytes()
|
|
got := hex.EncodeToString(point_bytes[:])
|
|
if got != expected {
|
|
t.Fatalf("point does not equal expected hex value, expected %s got %s", expected, got)
|
|
}
|
|
}
|
|
func ScalarEqualHex(t *testing.T, scalar fr.Element, expected string) {
|
|
scalar_bytes := scalar.BytesLE()
|
|
got := hex.EncodeToString(scalar_bytes[:])
|
|
if got != expected {
|
|
t.Fatalf("scalar does not equal expected hex value, expected %s got %s", expected, got)
|
|
}
|
|
}
|