Skip to content
Open
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: 6 additions & 0 deletions packages/wasm-privacy-coin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
1 change: 1 addition & 0 deletions packages/wasm-privacy-coin/proto/privacy_coin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ message AppendCommitmentsRequest {
uint32 block_height = 1;
repeated bytes commitments = 2; // each exactly 32 bytes (cmx)
optional bytes expected_root = 3; // 32 bytes; absent = skip verification
repeated bool owned = 4; // per-commitment ownership flag; absent/empty = all not-owned
}

message TruncateRequest {
Expand Down
3 changes: 2 additions & 1 deletion packages/wasm-privacy-coin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ pub unsafe extern "C" fn append_commitments(ptr: *const u8, len: u32) -> i32 {
Some(tree) => {
let commitments: Vec<Vec<u8>> =
req.commitments.iter().map(|b| b.to_vec()).collect();
let owned = req.owned;
let exp = expected_root.as_deref();
match tree.append_commitments(req.block_height, commitments, exp) {
match tree.append_commitments(req.block_height, commitments, owned, exp) {
Ok(root) => write_ok_bytes(root),
Err(e) => {
let (code, msg) = split_error(&e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ public void ping() {
*
* @param blockHeight block height (u32 range)
* @param commitments shielded note commitment values (cmx) for this block
* @param owned per-commitment ownership flags; {@code null} or shorter list → remaining are false
* @param expectedRoot root to verify against; {@code null} to skip
* @return computed root after appending
* @throws WasmException with code {@code ROOT_MISMATCH} if verification fails
*/
public ShieldedRoot appendCommitments(
long blockHeight, List<ShieldedCommitment> commitments, ShieldedRoot expectedRoot) {
long blockHeight, List<ShieldedCommitment> commitments, List<Boolean> owned,
ShieldedRoot expectedRoot) {
requireU32(blockHeight, "blockHeight");
Objects.requireNonNull(commitments, "commitments must not be null");

Expand All @@ -115,6 +117,9 @@ public ShieldedRoot appendCommitments(
.addAllCommitments(commitments.stream()
.map(c -> ByteString.copyFrom(c.bytes()))
.toList());
if (owned != null && !owned.isEmpty()) {
req.addAllOwned(owned);
}
if (expectedRoot != null) {
req.setExpectedRoot(ByteString.copyFrom(expectedRoot.bytes()));
}
Expand All @@ -123,11 +128,6 @@ public ShieldedRoot appendCommitments(
return ShieldedRoot.of(unwrap(r, resp -> resp.getBytesValue().toByteArray()));
}

/** Convenience overload — appends without root verification. */
public ShieldedRoot appendCommitments(long blockHeight, List<ShieldedCommitment> commitments) {
return appendCommitments(blockHeight, commitments, null);
}

/**
* Rolls the tree back to the checkpoint at the given block height.
*
Expand Down
Loading
Loading