Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-platform compatibility #502

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion group/curve25519/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Param struct {

P big.Int // Prime defining the underlying field
Q big.Int // Order of the prime-order base point
R int // Cofactor: Q*R is the total size of the curve
R int64 // Cofactor: Q*R is the total size of the curve

A, D big.Int // Edwards curve equation parameters

Expand Down
4 changes: 2 additions & 2 deletions internal/test/threshold.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// ThresholdTest performs a simple check on a threshold scheme implementation
func ThresholdTest(test *testing.T, keyGroup kyber.Group, scheme sign.ThresholdScheme) {
msg := []byte("Hello threshold Boneh-Lynn-Shacham")
n := 10
n := uint32(10)
t := n/2 + 1
test.Run("Correct sharing and recovering", func(tt *testing.T) {
secret := keyGroup.Scalar().Pick(random.New())
Expand Down Expand Up @@ -85,7 +85,7 @@ func ThresholdTest(test *testing.T, keyGroup kyber.Group, scheme sign.ThresholdS
fakeShares := fakePriPoly.Shares(n)
fakeSigShares := make([][]byte, 0)
fakePubPoly := fakePriPoly.Commit(keyGroup.Point().Base())
for i := 0; i < n; i++ {
for i := uint32(0); i < n; i++ {
fakeSig, _ := scheme.Sign(fakeShares[i], msg)
fakeSigShares = append(fakeSigShares, fakeSig)
}
Expand Down
12 changes: 6 additions & 6 deletions proof/deniable.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// the Sigma-protocol proofs of any or all of the other participants.
// Different participants may produce different proofs of varying sizes,
// and may even consist of different numbers of steps.
func DeniableProver(suite Suite, self int, prover Prover,
func DeniableProver(suite Suite, self uint32, prover Prover,
verifiers []Verifier) Protocol {

return Protocol(func(ctx Context) []error {
Expand All @@ -25,7 +25,7 @@ func DeniableProver(suite Suite, self int, prover Prover,

type deniableProver struct {
suite Suite // Agreed-on ciphersuite for protocol
self int // Our own node number
self uint32 // Our own node number
sc Context // Clique protocol context

// verifiers for other nodes' proofs
Expand All @@ -43,14 +43,14 @@ type deniableProver struct {
err []error
}

func (dp *deniableProver) run(suite Suite, self int, prv Prover,
func (dp *deniableProver) run(suite Suite, self uint32, prv Prover,
vrf []Verifier, sc Context) []error {
dp.suite = suite
dp.self = self
dp.sc = sc
dp.prirand = sc.Random()

nnodes := len(vrf)
nnodes := uint32(len(vrf))
if self < 0 || self >= nnodes {
return []error{errors.New("out-of-range self node")}
}
Expand All @@ -60,7 +60,7 @@ func (dp *deniableProver) run(suite Suite, self int, prv Prover,
verr := errors.New("prover or verifier not run")
dp.err = make([]error, nnodes)
for i := range dp.err {
if i != self {
if uint32(i) != self {
dp.err[i] = verr
}
}
Expand Down Expand Up @@ -187,7 +187,7 @@ func (dp *deniableProver) challengeStep() error {
mix[j] ^= key[j]
}
}
if len(keys) <= dp.self || !bytes.Equal(keys[dp.self], dp.key) {
if uint32(len(keys)) <= dp.self || !bytes.Equal(keys[dp.self], dp.key) {
return errors.New("our own message was corrupted")
}

Expand Down
2 changes: 1 addition & 1 deletion proof/deniable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestDeniable(t *testing.T) {
vpval := map[string]kyber.Point{"B": B, "X": nodes[vi].X}
vrfs[vi] = vpred.Verifier(suite, vpval)

n.proto = DeniableProver(suite, i, prover, vrfs)
n.proto = DeniableProver(suite, uint32(i), prover, vrfs)
n.outbox = make(chan []byte)
n.inbox = make(chan [][]byte)

Expand Down
4 changes: 2 additions & 2 deletions proof/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func Example_hashProve2() {
}

// Make just one of them an actual public/private keypair (X[mine],x)
mine := 2 // only the signer knows this
mine := int32(2) // only the signer knows this
x := suite.Scalar().Pick(suite.RandomStream()) // create a private key x
X[mine] = suite.Point().Mul(x, nil) // corresponding public key X

Expand All @@ -116,7 +116,7 @@ func Example_hashProve2() {
fmt.Printf("Linkable Ring Signature Predicate:\n%s\n", pred.String())

// The prover needs to know which Or branch (mine) is actually true.
choice := make(map[Predicate]int)
choice := make(map[Predicate]int32)
choice[pred] = mine

// Generate the signature
Expand Down
40 changes: 20 additions & 20 deletions proof/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Predicate interface {

// Create a Prover proving the statement this Predicate represents.
Prover(suite Suite, secrets map[string]kyber.Scalar,
points map[string]kyber.Point, choice map[Predicate]int) Prover
points map[string]kyber.Point, choice map[Predicate]int32) Prover

// Create a Verifier for the statement this Predicate represents.
Verifier(suite Suite, points map[string]kyber.Point) Verifier
Expand Down Expand Up @@ -103,17 +103,17 @@ const (
type proof struct {
s Suite

nsvars int // number of Scalar variables
npvars int // number of Point variables
svar, pvar []string // Scalar and Point variable names
sidx, pidx map[string]int // Maps from strings to variable indexes
nsvars uint32 // number of Scalar variables
npvars uint32 // number of Point variables
svar, pvar []string // Scalar and Point variable names
sidx, pidx map[string]uint32 // Maps from strings to variable indexes

pval map[string]kyber.Point // values of public Point variables

// prover-specific state
pc ProverContext
sval map[string]kyber.Scalar // values of private Scalar variables
choice map[Predicate]int // OR branch choices set by caller
choice map[Predicate]int32 // OR branch choices set by caller
pp map[Predicate]*proverPred // per-predicate prover state

// verifier-specific state
Expand Down Expand Up @@ -317,7 +317,7 @@ func (rp *repPred) verify(prf *proof, c kyber.Scalar, pr []kyber.Scalar) error {

func (rp *repPred) Prover(suite Suite, secrets map[string]kyber.Scalar,
points map[string]kyber.Point,
choice map[Predicate]int) Prover {
choice map[Predicate]int32) Prover {
return proof{}.init(suite, rp).prover(rp, secrets, points, choice)
}

Expand Down Expand Up @@ -427,7 +427,7 @@ func (ap *andPred) verify(prf *proof, c kyber.Scalar, pr []kyber.Scalar) error {

func (ap *andPred) Prover(suite Suite, secrets map[string]kyber.Scalar,
points map[string]kyber.Point,
choice map[Predicate]int) Prover {
choice map[Predicate]int32) Prover {
return proof{}.init(suite, ap).prover(ap, secrets, points, choice)
}

Expand Down Expand Up @@ -488,12 +488,12 @@ func (op *orPred) commit(prf *proof, w kyber.Scalar, pv []kyber.Scalar) error {
// We're on a proof-obligated branch;
// choose random pre-challenges for only non-obligated subs.
choice, ok := prf.choice[op]
if !ok || choice < 0 || choice >= len(sub) {
if !ok || choice < 0 || choice >= int32(len(sub)) {
return errors.New("no choice of proof branch for OR-predicate " +
op.String())
}
for i := 0; i < len(sub); i++ {
if i != choice {
if int32(i) != choice {
wi[i] = prf.s.Scalar()
prf.pc.PriRand(wi[i])
} // else wi[i] == nil for proof-obligated sub
Expand Down Expand Up @@ -536,7 +536,7 @@ func (op *orPred) respond(prf *proof, c kyber.Scalar, pr []kyber.Scalar) error {
cs := prf.s.Scalar().Set(c)
choice := prf.choice[op]
for i := 0; i < len(sub); i++ {
if i != choice {
if int32(i) != choice {
cs.Sub(cs, ci[i])
}
}
Expand Down Expand Up @@ -610,7 +610,7 @@ func (op *orPred) verify(prf *proof, c kyber.Scalar, pr []kyber.Scalar) error {

func (op *orPred) Prover(suite Suite, secrets map[string]kyber.Scalar,
points map[string]kyber.Point,
choice map[Predicate]int) Prover {
choice map[Predicate]int32) Prover {
return proof{}.init(suite, op).prover(op, secrets, points, choice)
}

Expand Down Expand Up @@ -641,25 +641,25 @@ func (prf proof) init(suite Suite, pred Predicate) *proof {
// Reserve variable index 0 for convenience.
prf.svar = []string{""}
prf.pvar = []string{""}
prf.sidx = make(map[string]int)
prf.pidx = make(map[string]int)
prf.sidx = make(map[string]uint32)
prf.pidx = make(map[string]uint32)
pred.enumVars(&prf)
prf.nsvars = len(prf.svar)
prf.npvars = len(prf.pvar)
prf.nsvars = uint32(len(prf.svar))
prf.npvars = uint32(len(prf.pvar))

return &prf
}

func (prf *proof) enumScalarVar(name string) {
if prf.sidx[name] == 0 {
prf.sidx[name] = len(prf.svar)
prf.sidx[name] = uint32(len(prf.svar))
prf.svar = append(prf.svar, name)
}
}

func (prf *proof) enumPointVar(name string) {
if prf.pidx[name] == 0 {
prf.pidx[name] = len(prf.pvar)
prf.pidx[name] = uint32(len(prf.pvar))
prf.pvar = append(prf.pvar, name)
}
}
Expand Down Expand Up @@ -705,7 +705,7 @@ func (prf *proof) getResponses(pr []kyber.Scalar, r []kyber.Scalar) error {

func (prf *proof) prove(p Predicate, sval map[string]kyber.Scalar,
pval map[string]kyber.Point,
choice map[Predicate]int, pc ProverContext) error {
choice map[Predicate]int32, pc ProverContext) error {
prf.pc = pc
prf.sval = sval
prf.pval = pval
Expand Down Expand Up @@ -752,7 +752,7 @@ func (prf *proof) verify(p Predicate, pval map[string]kyber.Point,
// Produce a higher-order Prover embodying a given proof predicate.
func (prf *proof) prover(p Predicate, sval map[string]kyber.Scalar,
pval map[string]kyber.Point,
choice map[Predicate]int) Prover {
choice map[Predicate]int32) Prover {

return Prover(func(ctx ProverContext) error {
return prf.prove(p, sval, pval, choice, ctx)
Expand Down
4 changes: 2 additions & 2 deletions proof/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestRep(t *testing.T) {
Y := suite.Point().Mul(y, X)
R := suite.Point().Add(X, Y)

choice := make(map[Predicate]int)
choice := make(map[Predicate]int32)

// Simple single-secret predicate: prove X=x*B
log := Rep("X", "x", "B")
Expand Down Expand Up @@ -212,7 +212,7 @@ func Example_or2() {
// We'll need to tell the prover which Or clause is actually true.
// In this case clause 0, the first sub-predicate, is true:
// i.e., we know a secret x such that X=x*B.
choice := make(map[Predicate]int)
choice := make(map[Predicate]int32)
choice[pred] = 0

// Generate a proof that we know the discrete logarithm of X or Y.
Expand Down
Loading
Loading