Skip to content

Enrique/compliance var size only#157

Closed
larraia wants to merge 3 commits into
mainfrom
enrique/compliance_var_size_only
Closed

Enrique/compliance var size only#157
larraia wants to merge 3 commits into
mainfrom
enrique/compliance_var_size_only

Conversation

@larraia

@larraia larraia commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Single compliance unit per action

@XuyangSong XuyangSong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your work!
I’ll rebase the branch, address the feedback, and refactor

Comment thread arm/src/action.rs
/// and verification of the action.
pub fn construct_action_tree(tags: &[Digest]) -> MerkleTree {
let mut ordered_tags = tags.to_vec();
ordered_tags.sort();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the compliance tag order to avoid adding sorting logic on both frontend and verifier sides

Comment thread arm/src/compliance.rs
pub fn from_resources_info_with_eph_root(
consumed_data: &[ConsumedDatum],
created_resources: &[Resource],
latest_root: Digest,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version isn’t required, valid_root works fine

Comment thread arm/src/compliance.rs
Comment on lines +49 to +58
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],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments to these two methods: specify only the additional valid root for ephemeral resources

Comment thread arm/src/compliance.rs
}

/// This module self-contains all enforced constraints.
mod constraints {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize this mod, a brief note for myself

Comment thread arm/src/resource.rs
Comment on lines +249 to +250
bytes[0..4].clone_from_slice(&index_u32.to_le_bytes());
bytes[4..DIGEST_BYTES + 4].clone_from_slice(nullifiers_digest.as_ref());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add personalization bytes here

Comment thread arm/src/logic_proof.rs
@@ -1,11 +1,11 @@
use crate::{
constants::{PADDING_LOGIC_PK, PADDING_LOGIC_VK},
constants::{TRIVIAL_LOGIC_PK, TRIVIAL_LOGIC_VK},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need the trivial logic for padding in actions with no consumed resources. Add comments and instructions

Comment thread arm/src/resource_logic.rs
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now use padding only for consumed resources. Should we hardcode the is_consumed flag?

Comment thread arm/src/resource.rs
bytes.append(&mut nf.as_bytes().to_vec().clone());
}

Impl::hash_bytes(&bytes).as_bytes().try_into().unwrap()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of the unwrap and return an error

Comment thread arm/src/resource.rs
Comment on lines +233 to 240
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)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle the case where nullifiers are empty, return a proper error

@XuyangSong

Copy link
Copy Markdown
Collaborator

superceded by #220

@XuyangSong XuyangSong closed this May 25, 2026
@github-project-automation github-project-automation Bot moved this from Triage to Closed in Anoma SDK - What's Cooking May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants