feat: expose Builder.signDataHashedEmbeddable#1
Open
deblanco wants to merge 2 commits into
Open
Conversation
Adds Neon bindings + TS wrappers for c2pa-rs `Builder::sign_data_hashed_embeddable` (sync) and its async variant. Produces a signed embeddable manifest from a pre-computed `DataHash`, without needing the asset bytes at sign time. Targets sidecar `.c2pa` and remote-manifest workflows. The binding calls `data_hashed_placeholder` internally before signing (required by upstream to reserve the DataHash assertion slot); the placeholder bytes are discarded since callers in this flow do not embed them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builder::sign_data_hashed_embeddableAPI in the JS wrapper asBuilder.signDataHashedEmbeddable(sync,LocalSigner) andBuilder.signDataHashedEmbeddableAsync(async,CallbackSigner).DataHash(e.g. rawSHA-256of the asset) without needing the asset bytes at sign time. Targets sidecar.c2paand remote-manifest workflows.DataHashtype tojs-src/types.d.tsmirroring the c2pa-rsDataHashserde struct:{ name?, alg?, hash, pad?, exclusions? }.hash/padacceptBuffer | Uint8Array | number[];exclusionsaccepts{ start, length }[].Builder::data_hashed_placeholderinternally before the sign call (required by upstream c2pa-rs to reserve the DataHash assertion slot in the builder definition); placeholder bytes are discarded since callers in this flow do not embed them.### Builderwith sync + async examples.Files
src/neon_builder.rs— two new Neon methods.src/lib.rs— registersbuilderSignDataHashedEmbeddable+builderSignDataHashedEmbeddableAsync.js-src/index.node.d.ts— neon function declarations.js-src/types.d.ts—DataHashinterface + two methods onBuilderInterface.js-src/Builder.ts— public wrapper methods +serializeDataHashhelper that normalizesBuffer/Uint8Arraytonumber[](c2pa-rsDataHashusesserde_bytes, which deserializes JSON arrays of u8, not the defaultBuffer.toJSON()shape).js-src/Builder.spec.ts— two new vitest cases (sync + async).README.md— usage docs.API
With
exclusions: []andalg: "sha256", the resultingc2pa.hash.data.hashequalsSHA-256(asset)— a verifier with the original file recomputes the same digest and the manifest validates.Test plan
cargo build— cleancargo clippy— cleantsc -b— cleaneslint— clean (Builder.ts,Builder.spec.ts)vitest run js-src/Builder.spec.ts— 23/23 pass (incl. 2 new tests for sync + async DataHash signing)c2patool verifyagainst a fixture + sidecar produced by the new APINotes
sign_data_hashed_embeddable(no_manifestsuffix — that lives on the internalStore::get_data_hashed_embeddable_manifest). This PR binds to the public API.Builder::sign_data_hashed_embeddable_async, available in c2pa-rs 0.82.1 via theasync_genericmacro on the same method.