1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

Apply suggestions from code review

thanks @Schaeff

Co-Authored-By: stefandeml <stefandeml@gmail.com>
This commit is contained in:
Thibaut Schaeffer 2019-03-19 12:46:22 +01:00 committed by GitHub
parent 5ae8310331
commit a139e379ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 20 deletions

View file

@ -43,7 +43,7 @@ import "ecc/proofOfOwnership.code"
Verifies match of a given public/private keypair. Checks if the following equation holds for the provided keypair:
`pk = sk*G`
where `G` is the chosen base point of the subgroup and `*` denotes scalar multiplication.
where `G` is the chosen base point of the subgroup and `*` denotes scalar multiplication in the subgroup.
#### Signature verification
@ -51,7 +51,7 @@ where `G` is the chosen base point of the subgroup and `*` denotes scalar multip
import "signatures/verifyEddsa.code"
```
Verifies an EdDSA Signature. Checks the correctness of a given EdDSA Signature (`R,S`) for the provided public key(`A`) and message (`M0` and `M1`).
Verifies an EdDSA Signature. Checks the correctness of a given EdDSA Signature `(R,S)` for the provided public key `A` and message `(M0, M1)`.
### Packing / Unpacking
@ -77,4 +77,4 @@ Unpacks a field element to 128 field elements.
import "utils/pack/unpack256"
```
Unpacks a field element to 256 field elements.
Unpacks a field element to 256 field elements.

View file

@ -1,7 +1,7 @@
[package]
name = "zokrates_stdlib"
version = "0.1.0"
authors = ["schaeff <thibaut@schaeff.fr>", "Stefan Deml <stefandeml@gmail.com>"]
authors = ["Stefan Deml <stefandeml@gmail.com>", "schaeff <thibaut@schaeff.fr>"]
edition = "2018"
[features]

View file

@ -1,5 +1,5 @@
// Parameters are based on: https://github.com/HarryR/ethsnarks/tree/master/src/jubjub
// Note: parameters will be update soon to be more compatible with zCash's implementation
// Note: parameters will be updated soon to be more compatible with zCash's implementation
def main() -> (field[10]):
// Order of the curve E
@ -19,4 +19,4 @@ def main() -> (field[10]):
// Index
// 0 1 2 3 4 5 6 7 8 10
return [JUBJUBA, JUBJUBD, infinity[0], infinity[1], Gu, Gv, JUBJUBE, JUBJUBC, MONTA, MONTB]
return [JUBJUBA, JUBJUBD, infinity[0], infinity[1], Gu, Gv, JUBJUBE, JUBJUBC, MONTA, MONTB]

View file

@ -1,5 +1,5 @@
import "ecc/babyjubjubParams.code" as context
// Function adds two points on a twisted Edwards curve
// Add two points on a twisted Edwards curve
// Curve parameters are defined with the last argument
// https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Addition_on_twisted_Edwards_curves
def main(field[2] pt1, field[2] pt2, field[10] context) -> (field[2]):
@ -15,4 +15,4 @@ def main(field[2] pt1, field[2] pt2, field[10] context) -> (field[2]):
field uOut = (u1*v2 + v1*u2) / (1 + d*u1*u2*v1*v2)
field vOut = (v1*v2 - a*u1*u2) / (1 - d*u1*u2*v1*v2)
return [uOut, vOut]
return [uOut, vOut]

View file

@ -1,5 +1,5 @@
import "ecc/babyjubjubParams.code" as context
// Function negates a given edwards point.
// Negate a point on an Edwards curve
// Curve parameters are defined with the last argument
// Twisted Edwards Curves, BBJLP-2008, section 2 pg 2
def main(field[2] pt, field[10] context) -> (field[2]):
@ -7,4 +7,4 @@ def main(field[2] pt, field[10] context) -> (field[2]):
field u = pt[0]
field v = pt[1]
return [0-u, v]
return [0-u, v]

View file

@ -1,4 +1,4 @@
// Function checks if a provided point is on a twisted Edwards curve
// Check if a point is on a twisted Edwards curve
// Curve parameters are defined with the last argument
// See appendix 3.3.1 of Zcash protocol specification:
// https://github.com/zcash/zips/blob/master/protocol/protocol.pdf

View file

@ -4,7 +4,7 @@ import "utils/pack/unpack256.code" as unpack256
// Verifies that the point is not one of the low-order points.
// If any of the points is multiplied by the cofactor, the resulting point
// will be infinity.
// Returns true if the point is not one of the low-order points, false otherwise.
// Returns 1 if the point is not one of the low-order points, 0 otherwise.
// Curve parameters are defined with the last argument
// https://github.com/zcash-hackworks/sapling-crypto/blob/master/src/jubjub/edwards.rs#L166
def main(field[2] pt, field[10] context) -> (field):
@ -16,4 +16,4 @@ def main(field[2] pt, field[10] context) -> (field):
field out = if ptExp[0] == 0 && ptExp[1] == 1 then 0 else 1 fi
return out
return out

View file

@ -7,7 +7,7 @@ import "utils/pack/unpack256.code" as unpack256
/// Checks if the following equation holds for the provided keypair:
/// pk = sk*G
/// where G is the chosen base point of the subgroup
/// and * denotes scalar multiplication
/// and * denotes scalar multiplication in the subgroup
///
/// Arguments:
/// pk: Curve point. Public key.
@ -15,7 +15,7 @@ import "utils/pack/unpack256.code" as unpack256
/// context: Curve parameters (including generator G) used to create keypair.
///
/// Returns:
/// Return true for pk/sk being a valid keypair, false otherwise.
/// Return 1 for pk/sk being a valid keypair, 0 otherwise.
def main(field[2] pk, field sk, field[10] context) -> (field):
field[2] G = [context[4], context[5]]
@ -25,4 +25,4 @@ def main(field[2] pk, field sk, field[10] context) -> (field):
field out = if ptExp[0] == pk[0] && ptExp[1] == pk[1] then 1 else 0 fi
return out
return out

View file

@ -1,5 +1,5 @@
import "./1536bit.code" as sha256
// A function that takes 2 field[256] arrays as inputs
// Take two field[256] arrays as input
// and returns their sha256 full round output as an array of 256 field elements.
def main(field[256] a, field[256] b, field[256] c, field[256] d) -> (field[256]):
@ -12,4 +12,4 @@ def main(field[256] a, field[256] b, field[256] c, field[256] d) -> (field[256])
digest = sha256(a, b, c, d, dummyblock1, dummyblock2)
return digest
return digest

View file

@ -8,7 +8,7 @@ import "ecc/edwardsOrderCheck.code" as orderCheck
/// Verifies an EdDSA Signature.
///
/// Checks the correctness of a given EdDSA Signature (R,S) for the provided
/// public key(A) and message (M0 and M1).
/// public key A and message (M0, M1).
/// For more information see:
/// https://en.wikipedia.org/wiki/EdDSA
/// https://eprint.iacr.org/2015/677.pdf
@ -22,7 +22,7 @@ import "ecc/edwardsOrderCheck.code" as orderCheck
/// context: Curve parameters used to create S.
///
/// Returns:
/// Return true for S being a valid EdDSA Signature, false otherwise.
/// Return 1 for S being a valid EdDSA Signature, 0 otherwise.
def main(private field[2] R, private field S, field[2] A, field[256] M0, field[256] M1, field[10] context) -> (field):
field[2] G = [context[4], context[5]]