Pin halo2 commit and update usage of pasta_curves accordingly

This commit is contained in:
Deirdre Connolly 2021-04-29 00:21:37 -04:00
parent 9b6339bb9c
commit 6d4ecff24b
5 changed files with 39 additions and 25 deletions

2
Cargo.lock generated
View File

@ -1510,7 +1510,7 @@ checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3"
[[package]]
name = "halo2"
version = "0.0.1"
source = "git+https://github.com/zcash/halo2.git?branch=main#b079624ea78b4a07d44cb3c725dd734093577062"
source = "git+https://github.com/zcash/halo2.git?rev=dda60a363001373d564156ad0334e2022d85a5b4#dda60a363001373d564156ad0334e2022d85a5b4"
dependencies = [
"blake2b_simd",
"crossbeam-utils 0.8.0",

View File

@ -29,7 +29,8 @@ fpe = "0.4"
funty = "=1.1.0"
futures = "0.3"
group = "0.9"
halo2 = { git = "https://github.com/zcash/halo2.git", branch = "main" }
# TODO: replace w/ crate version when released: https://github.com/ZcashFoundation/zebra/issues/2083
halo2 = { git = "https://github.com/zcash/halo2.git", rev = "dda60a363001373d564156ad0334e2022d85a5b4"}
hex = "0.4"
jubjub = "0.6.0"
lazy_static = "1.4.0"

View File

@ -5,7 +5,7 @@ use std::{convert::TryFrom, fmt, io};
use bitvec::prelude::*;
use group::{prime::PrimeCurveAffine, GroupEncoding};
use halo2::{
arithmetic::{CurveAffine, FieldExt},
arithmetic::{Coordinates, CurveAffine, FieldExt},
pasta::pallas,
};
use lazy_static::lazy_static;
@ -61,10 +61,12 @@ impl fmt::Debug for NoteCommitment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut d = f.debug_struct("NoteCommitment");
match self.0.get_xy().into() {
Some((x, y)) => d
.field("x", &hex::encode(x.to_bytes()))
.field("y", &hex::encode(y.to_bytes()))
let option: Option<Coordinates<pallas::Affine>> = self.0.coordinates().into();
match option {
Some(coordinates) => d
.field("x", &hex::encode(coordinates.x().to_bytes()))
.field("y", &hex::encode(coordinates.y().to_bytes()))
.finish(),
None => d
.field("x", &hex::encode(pallas::Base::zero().to_bytes()))
@ -167,9 +169,11 @@ impl NoteCommitment {
///
/// https://zips.z.cash/protocol/nu5.pdf#concreteextractorpallas
pub fn extract_x(&self) -> pallas::Base {
match self.0.get_xy().into() {
let option: Option<Coordinates<pallas::Affine>> = self.0.coordinates().into();
match option {
// If Some, it's not the identity.
Some((x, _)) => x,
Some(coordinates) => *coordinates.x(),
_ => pallas::Base::zero(),
}
}
@ -208,10 +212,12 @@ impl fmt::Debug for ValueCommitment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut d = f.debug_struct("ValueCommitment");
match self.0.get_xy().into() {
Some((x, y)) => d
.field("x", &hex::encode(x.to_bytes()))
.field("y", &hex::encode(y.to_bytes()))
let option: Option<Coordinates<pallas::Affine>> = self.0.coordinates().into();
match option {
Some(coordinates) => d
.field("x", &hex::encode(coordinates.x().to_bytes()))
.field("y", &hex::encode(coordinates.y().to_bytes()))
.finish(),
None => d
.field("x", &hex::encode(pallas::Base::zero().to_bytes()))

View File

@ -20,7 +20,7 @@ use bitvec::prelude::*;
use fpe::ff1::{BinaryNumeralString, FF1};
use group::{Group, GroupEncoding};
use halo2::{
arithmetic::{CurveAffine, FieldExt},
arithmetic::{Coordinates, CurveAffine, FieldExt},
pasta::pallas,
};
use rand_core::{CryptoRng, RngCore};
@ -854,10 +854,12 @@ impl fmt::Debug for TransmissionKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut d = f.debug_struct("TransmissionKey");
match self.0.get_xy().into() {
Some((x, y)) => d
.field("x", &hex::encode(x.to_bytes()))
.field("y", &hex::encode(y.to_bytes()))
let option: Option<Coordinates<pallas::Affine>> = self.0.coordinates().into();
match option {
Some(coordinates) => d
.field("x", &hex::encode(coordinates.x().to_bytes()))
.field("y", &hex::encode(coordinates.y().to_bytes()))
.finish(),
None => d
.field("x", &hex::encode(pallas::Base::zero().to_bytes()))
@ -917,10 +919,12 @@ impl fmt::Debug for EphemeralPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut d = f.debug_struct("EphemeralPublicKey");
match self.0.get_xy().into() {
Some((x, y)) => d
.field("x", &hex::encode(x.to_bytes()))
.field("y", &hex::encode(y.to_bytes()))
let option: Option<Coordinates<pallas::Affine>> = self.0.coordinates().into();
match option {
Some(coordinates) => d
.field("x", &hex::encode(coordinates.x().to_bytes()))
.field("y", &hex::encode(coordinates.y().to_bytes()))
.finish(),
None => d
.field("x", &hex::encode(pallas::Base::zero().to_bytes()))

View File

@ -3,7 +3,7 @@
use bitvec::prelude::*;
use halo2::{
arithmetic::{CurveAffine, CurveExt},
arithmetic::{Coordinates, CurveAffine, CurveExt},
pasta::pallas,
};
@ -13,9 +13,12 @@ use halo2::{
///
/// [concreteextractorpallas]: https://zips.z.cash/protocol/nu5.pdf#concreteextractorpallas
pub fn extract_p(point: pallas::Point) -> pallas::Base {
match pallas::Affine::from(point).get_xy().into() {
let option: Option<Coordinates<pallas::Affine>> =
pallas::Affine::from(point).coordinates().into();
match option {
// If Some, it's not the identity.
Some((x, _)) => x,
Some(coordinates) => *coordinates.x(),
_ => pallas::Base::zero(),
}
}