Follow portable CultNet provider signature bytes

This commit is contained in:
Meta Vens 2026-07-22 02:15:35 +01:00
commit a7647a1660
2 changed files with 7 additions and 8 deletions

View file

@ -25,13 +25,12 @@ export function createSignedPersonaFeedbackHealth(input){
if(!isUuid(input.publisherIncarnationId))throw new Error("Bifrost Persona-feedback publisher incarnation must be a UUID.");
if(!Number.isSafeInteger(input.publisherSequence)||input.publisherSequence<=0)throw new Error("Bifrost Persona-feedback publisher sequence must be a positive safe integer.");
const observed=Number(input.observedAtUnixMillis??Date.now());if(!Number.isSafeInteger(observed)||observed<=0)throw new Error("Bifrost Persona-feedback observation time must be positive Unix milliseconds.");
// Rust's canonical positional contract represents Vec<u8> as a MessagePack
// integer array. Uint8Array lowers to bin8 and is therefore a different
// signed payload even though both decode to bytes in JavaScript.
// The shared CultNet contract marks signatures as portable bytes, so both
// Rust and JavaScript lower this field as MessagePack binary.
// Safe JavaScript numbers above u32 lower as float64. Rust's u64 lowers as
// uint64, so retain the timestamp as BigInt on this signed wire surface.
const provider=providerHealthIdentity(input.identity),record=[schema,input.daemonId,input.healthContract,sourceRuntimeId,input.state,input.detail,provider.identityId,input.publisherIncarnationId,input.publisherSequence,BigInt(observed),null,null,null,null,"ed25519",[],false];
const proof=signProviderHealth(input.identity,canonicalHealthEncode(record));if(proof.identityId!==provider.identityId)throw new Error("Provider-health signer identity derivation disagrees with the packet.");record[15]=Array.from(proof.signature);
const provider=providerHealthIdentity(input.identity),record=[schema,input.daemonId,input.healthContract,sourceRuntimeId,input.state,input.detail,provider.identityId,input.publisherIncarnationId,input.publisherSequence,BigInt(observed),null,null,null,null,"ed25519",new Uint8Array(),false];
const proof=signProviderHealth(input.identity,canonicalHealthEncode(record));if(proof.identityId!==provider.identityId)throw new Error("Provider-health signer identity derivation disagrees with the packet.");record[15]=new Uint8Array(proof.signature);
return {record,payload:canonicalHealthEncode(record),providerIdentityId:provider.identityId,observedAtUnixMillis:observed};
}