Enrique/compliance var size only#157
Conversation
Update feature gating for building to wasm32
XuyangSong
left a comment
There was a problem hiding this comment.
thanks for your work!
I’ll rebase the branch, address the feedback, and refactor
| /// and verification of the action. | ||
| pub fn construct_action_tree(tags: &[Digest]) -> MerkleTree { | ||
| let mut ordered_tags = tags.to_vec(); | ||
| ordered_tags.sort(); |
There was a problem hiding this comment.
Use the compliance tag order to avoid adding sorting logic on both frontend and verifier sides
| pub fn from_resources_info_with_eph_root( | ||
| consumed_data: &[ConsumedDatum], | ||
| created_resources: &[Resource], | ||
| latest_root: Digest, |
There was a problem hiding this comment.
The latest version isn’t required, valid_root works fine
| pub fn from_resources_info( | ||
| consumed_data: &[ConsumedDatum], | ||
| created_resources: &[Resource], | ||
| ) -> Self { | ||
| let mut rng = rand::thread_rng(); | ||
| ComplianceWitness { | ||
| consumed_resource, | ||
| created_resource, | ||
| merkle_path: MerklePath::empty(), | ||
| rcv: Scalar::random(&mut rng).to_bytes().to_vec(), | ||
| nf_key, | ||
| ephemeral_root: latest_root, | ||
| } | ||
| Self::from_resources_info_with_eph_root(consumed_data, created_resources, *INITIAL_ROOT) | ||
| } | ||
|
|
||
| pub fn from_resources_with_path( | ||
| consumed_resource: Resource, | ||
| nf_key: NullifierKey, | ||
| merkle_path: MerklePath, | ||
| created_resource: Resource, | ||
| pub fn from_resources_info_with_eph_root( | ||
| consumed_data: &[ConsumedDatum], | ||
| created_resources: &[Resource], |
There was a problem hiding this comment.
Add comments to these two methods: specify only the additional valid root for ephemeral resources
| } | ||
|
|
||
| /// This module self-contains all enforced constraints. | ||
| mod constraints { |
There was a problem hiding this comment.
Optimize this mod, a brief note for myself
| bytes[0..4].clone_from_slice(&index_u32.to_le_bytes()); | ||
| bytes[4..DIGEST_BYTES + 4].clone_from_slice(nullifiers_digest.as_ref()); |
There was a problem hiding this comment.
Add personalization bytes here
| @@ -1,11 +1,11 @@ | |||
| use crate::{ | |||
| constants::{PADDING_LOGIC_PK, PADDING_LOGIC_VK}, | |||
| constants::{TRIVIAL_LOGIC_PK, TRIVIAL_LOGIC_VK}, | |||
There was a problem hiding this comment.
We still need the trivial logic for padding in actions with no consumed resources. Add comments and instructions
| Ok(LogicInstance { | ||
| tag, | ||
| is_consumed: self.is_consumed, // It can be either consumed or created to reduce padding resources | ||
| is_consumed: self.is_consumed, // It can be either consumed or created |
There was a problem hiding this comment.
We now use padding only for consumed resources. Should we hardcode the is_consumed flag?
| bytes.append(&mut nf.as_bytes().to_vec().clone()); | ||
| } | ||
|
|
||
| Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap() |
There was a problem hiding this comment.
get rid of the unwrap and return an error
| pub fn derive_nonce_from_nullifiers( | ||
| index: usize, | ||
| nullifiers: &[Digest], | ||
| ) -> Result<[u8; 32], ArmError> { | ||
| let nullifiers_digest = Self::hash_nullifiers(nullifiers); | ||
|
|
||
| Self::derive_nonce(index, nullifiers_digest) | ||
| } |
There was a problem hiding this comment.
Handle the case where nullifiers are empty, return a proper error
|
superceded by #220 |
Single compliance unit per action