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

Bump dependency versions #196

Merged
merged 4 commits into from
Aug 7, 2023
Merged
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
6 changes: 3 additions & 3 deletions taiga_halo2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ subtle = { version = "2.3", default-features = false }
dyn-clone = "1.0"
reddsa = "0.5"
vamp-ir = { git = "https://github.com/anoma/vamp-ir.git", rev = "6d401f8a479951727586ef0c44c42edab3139090"}
bincode = "2.0.0-rc.1"
borsh = {version = "0.9", features = ["const-generics"]}
bincode = "2.0.0-rc.3"
borsh = {version = "0.10.3", features = ["const-generics"]}
byteorder = "1"
num-bigint = "0.4.3"

[dev-dependencies]
criterion = "0.3"
criterion = "0.5.1"
proptest = "1.0.0"

[[bench]]
Expand Down
10 changes: 5 additions & 5 deletions taiga_halo2/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ impl BorshSerialize for ActionInstance {
}

impl BorshDeserialize for ActionInstance {
fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result<Self> {
let anchor_bytes = <[u8; 32]>::deserialize(buf)?;
fn deserialize_reader<R: io::Read>(reader: &mut R) -> io::Result<Self> {
let anchor_bytes = <[u8; 32]>::deserialize_reader(reader)?;
let anchor = Option::from(pallas::Base::from_repr(anchor_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "anchor not in field"))?;
let nf_bytes = <[u8; 32]>::deserialize(buf)?;
let nf_bytes = <[u8; 32]>::deserialize_reader(reader)?;
let nf = Option::from(Nullifier::from_bytes(nf_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "nf not in field"))?;
let cm_x_bytes = <[u8; 32]>::deserialize(buf)?;
let cm_x_bytes = <[u8; 32]>::deserialize_reader(reader)?;
let cm_x = Option::from(pallas::Base::from_repr(cm_x_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "cm_x not in field"))?;
let cv_net_bytes = <[u8; 32]>::deserialize(buf)?;
let cv_net_bytes = <[u8; 32]>::deserialize_reader(reader)?;
let cv_net = Option::from(ValueCommitment::from_bytes(cv_net_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "cv_net not in field"))?;

Expand Down
10 changes: 6 additions & 4 deletions taiga_halo2/src/binding_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ impl BorshSerialize for BindingSignature {
}

impl BorshDeserialize for BindingSignature {
fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result<Self> {
let sig_bytes = <[u8; 64]>::deserialize(buf)?;
fn deserialize_reader<R: io::Read>(reader: &mut R) -> io::Result<Self> {
let mut sig_bytes = [0u8; 64];
reader.read_exact(&mut sig_bytes)?;
Ok(Self::from_bytes(sig_bytes))
}
}
Expand Down Expand Up @@ -87,8 +88,9 @@ impl BorshSerialize for BindingSigningKey {
}

impl BorshDeserialize for BindingSigningKey {
fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result<Self> {
let key_bytes = <[u8; 32]>::deserialize(buf)?;
fn deserialize_reader<R: io::Read>(reader: &mut R) -> io::Result<Self> {
let mut key_bytes = [0u8; 32];
reader.read_exact(&mut key_bytes)?;
Self::from_bytes(key_bytes).map_err(|_| {
io::Error::new(io::ErrorKind::InvalidData, "BindingSigningKey not in field")
})
Expand Down
8 changes: 4 additions & 4 deletions taiga_halo2/src/circuit/vp_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ impl BorshSerialize for VPVerifyingInfo {
}

impl BorshDeserialize for VPVerifyingInfo {
fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result<Self> {
fn deserialize_reader<R: io::Read>(reader: &mut R) -> io::Result<Self> {
// Read vk
use crate::circuit::vp_examples::TrivialValidityPredicateCircuit;
let params = SETUP_PARAMS_MAP.get(&VP_CIRCUIT_PARAMS_SIZE).unwrap();
let vk = VerifyingKey::read::<_, TrivialValidityPredicateCircuit>(buf, params)?;
let vk = VerifyingKey::read::<_, TrivialValidityPredicateCircuit>(reader, params)?;
// Read proof
let proof = Proof::deserialize(buf)?;
let proof = Proof::deserialize_reader(reader)?;
// Read public inputs
let public_inputs: Vec<_> = (0..VP_CIRCUIT_PUBLIC_INPUT_NUM)
.map(|_| {
let bytes = <[u8; 32]>::deserialize(buf)?;
let bytes = <[u8; 32]>::deserialize_reader(reader)?;
Option::from(pallas::Base::from_repr(bytes)).ok_or_else(|| {
io::Error::new(io::ErrorKind::InvalidData, "public input not in field")
})
Expand Down
33 changes: 22 additions & 11 deletions taiga_halo2/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,28 +320,34 @@ impl BorshSerialize for Note {
}

impl BorshDeserialize for Note {
fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result<Self> {
fn deserialize_reader<R: io::Read>(reader: &mut R) -> io::Result<Self> {
// Read app_vk
let app_vk_bytes = <[u8; 32]>::deserialize(buf)?;
let mut app_vk_bytes = [0u8; 32];
reader.read_exact(&mut app_vk_bytes)?;
let app_vk = Option::from(pallas::Base::from_repr(app_vk_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "app_vk not in field"))?;
// Read app_data_static
let app_data_static_bytes = <[u8; 32]>::deserialize(buf)?;
let mut app_data_static_bytes = [0u8; 32];
reader.read_exact(&mut app_data_static_bytes)?;
let app_data_static = Option::from(pallas::Base::from_repr(app_data_static_bytes))
.ok_or_else(|| {
io::Error::new(io::ErrorKind::InvalidData, "app_data_static not in field")
})?;
// Read app_data_dynamic
let app_data_dynamic_bytes = <[u8; 32]>::deserialize(buf)?;
let mut app_data_dynamic_bytes = [0u8; 32];
reader.read_exact(&mut app_data_dynamic_bytes)?;
let app_data_dynamic = Option::from(pallas::Base::from_repr(app_data_dynamic_bytes))
.ok_or_else(|| {
io::Error::new(io::ErrorKind::InvalidData, "app_data_dynamic not in field")
})?;
// Read note value
let value = buf.read_u64::<LittleEndian>()?;
let value = reader.read_u64::<LittleEndian>()?;
// Read nk_container
let nk_container_type = buf.read_u8()?;
let nk_container_bytes = <[u8; 32]>::deserialize(buf)?;
let mut nk_container_type = [0u8; 1];
reader.read_exact(&mut nk_container_type)?;
let nk_container_type = nk_container_type[0];
let mut nk_container_bytes = [0u8; 32];
reader.read_exact(&mut nk_container_bytes)?;
let nk = Option::from(pallas::Base::from_repr(nk_container_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "nk not in field"))?;
let nk_container = if nk_container_type == 0x01 {
Expand All @@ -350,19 +356,24 @@ impl BorshDeserialize for Note {
NullifierKeyContainer::from_key(nk)
};
// Read rho
let rho_bytes = <[u8; 32]>::deserialize(buf)?;
let mut rho_bytes = [0u8; 32];
reader.read_exact(&mut rho_bytes)?;
let rho = Option::from(Nullifier::from_bytes(rho_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "rho not in field"))?;
// Read psi
let psi_bytes = <[u8; 32]>::deserialize(buf)?;
let mut psi_bytes = [0u8; 32];
reader.read_exact(&mut psi_bytes)?;
let psi = Option::from(pallas::Base::from_repr(psi_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "psi not in field"))?;
// Read rcm
let rcm_bytes = <[u8; 32]>::deserialize(buf)?;
let mut rcm_bytes = [0u8; 32];
reader.read_exact(&mut rcm_bytes)?;
let rcm = Option::from(pallas::Base::from_repr(rcm_bytes))
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "rcm not in field"))?;
// Read is_merkle_checked
let is_merkle_checked_byte = buf.read_u8()?;
let mut is_merkle_checked_byte = [0u8; 1];
reader.read_exact(&mut is_merkle_checked_byte)?;
let is_merkle_checked_byte = is_merkle_checked_byte[0];
let is_merkle_checked = is_merkle_checked_byte == 0x01;
// Construct note
Ok(Note::from_full(
Expand Down
8 changes: 4 additions & 4 deletions taiga_halo2/src/shielded_ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ impl BorshSerialize for ShieldedPartialTransaction {
}

impl BorshDeserialize for ShieldedPartialTransaction {
fn deserialize(buf: &mut &[u8]) -> borsh::maybestd::io::Result<Self> {
fn deserialize_reader<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
let actions: Vec<_> = (0..NUM_NOTE)
.map(|_| ActionVerifyingInfo::deserialize(buf))
.map(|_| ActionVerifyingInfo::deserialize_reader(reader))
.collect::<Result<_, _>>()?;
let inputs: Vec<_> = (0..NUM_NOTE)
.map(|_| NoteVPVerifyingInfoSet::deserialize(buf))
.map(|_| NoteVPVerifyingInfoSet::deserialize_reader(reader))
.collect::<Result<_, _>>()?;
let outputs: Vec<_> = (0..NUM_NOTE)
.map(|_| NoteVPVerifyingInfoSet::deserialize(buf))
.map(|_| NoteVPVerifyingInfoSet::deserialize_reader(reader))
.collect::<Result<_, _>>()?;
Ok(ShieldedPartialTransaction {
actions: actions.try_into().unwrap(),
Expand Down
Loading