@transmute/cose
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -13,6 +13,6 @@ /// <reference types="node" /> | ||
leaf: (entry: Uint8Array) => Uint8Array; | ||
root: ({ leaves, signer, }: import("./types").RequestSignedMerkleRoot) => Promise<Uint8Array>; | ||
inclusion_proof: ({ log_id, leaf_index, leaves, signer, }: import("./types").RequestInclusionProof) => Promise<Uint8Array>; | ||
root: ({ alg, kid, leaves, signer, }: import("./types").RequestSignedMerkleRoot) => Promise<Uint8Array>; | ||
inclusion_proof: ({ kid, alg, leaf_index, leaves, signer, }: import("./types").RequestInclusionProof) => Promise<Uint8Array>; | ||
verify_inclusion_proof: ({ leaf, signed_inclusion_proof, verifier, }: import("./types").RequestInclusionProofVerification) => Promise<Uint8Array>; | ||
consistency_proof: ({ log_id, leaves, signed_inclusion_proof, signer, }: import("./types").RequestConsistencyProof) => Promise<Buffer>; | ||
consistency_proof: ({ kid, alg, leaves, signed_inclusion_proof, signer, }: import("./types").RequestConsistencyProof) => Promise<Buffer>; | ||
verify_consistency_proof: ({ old_root, signed_consistency_proof, verifier, }: import("./types").RequestConsistencyProofVerification) => Promise<boolean>; | ||
@@ -19,0 +19,0 @@ }; |
@@ -5,8 +5,8 @@ /// <reference types="node" /> | ||
leaf: (entry: Uint8Array) => Uint8Array; | ||
root: ({ leaves, signer, }: import("..").RequestSignedMerkleRoot) => Promise<Uint8Array>; | ||
inclusion_proof: ({ log_id, leaf_index, leaves, signer, }: import("..").RequestInclusionProof) => Promise<Uint8Array>; | ||
root: ({ alg, kid, leaves, signer, }: import("..").RequestSignedMerkleRoot) => Promise<Uint8Array>; | ||
inclusion_proof: ({ kid, alg, leaf_index, leaves, signer, }: import("..").RequestInclusionProof) => Promise<Uint8Array>; | ||
verify_inclusion_proof: ({ leaf, signed_inclusion_proof, verifier, }: import("..").RequestInclusionProofVerification) => Promise<Uint8Array>; | ||
consistency_proof: ({ log_id, leaves, signed_inclusion_proof, signer, }: import("..").RequestConsistencyProof) => Promise<Buffer>; | ||
consistency_proof: ({ kid, alg, leaves, signed_inclusion_proof, signer, }: import("..").RequestConsistencyProof) => Promise<Buffer>; | ||
verify_consistency_proof: ({ old_root, signed_consistency_proof, verifier, }: import("..").RequestConsistencyProofVerification) => Promise<boolean>; | ||
}; | ||
export default merkle; |
/// <reference types="node" /> | ||
import { RequestConsistencyProof } from '../types'; | ||
export declare const sign_consistency_proof: ({ log_id, leaves, signed_inclusion_proof, signer, }: RequestConsistencyProof) => Promise<Buffer>; | ||
export declare const sign_consistency_proof: ({ kid, alg, leaves, signed_inclusion_proof, signer, }: RequestConsistencyProof) => Promise<Buffer>; |
@@ -19,4 +19,3 @@ "use strict"; | ||
const cbor_1 = __importDefault(require("../cbor")); | ||
const { tree_alg } = rfc9162_1.CoMETRE.RFC9162_SHA256; | ||
const sign_consistency_proof = ({ log_id, leaves, signed_inclusion_proof, signer, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const sign_consistency_proof = ({ kid, alg, leaves, signed_inclusion_proof, signer, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const decoded = cbor_1.default.decode(signed_inclusion_proof); | ||
@@ -30,11 +29,7 @@ const [tree_size, leaf_index, inclusion_path] = cbor_1.default.decode(decoded.value[1].get(100)); | ||
}, leaves); | ||
const prefix = `urn:ietf:params:trans:consistency`; | ||
const leaf = leaves[leaf_index]; | ||
const new_root = rfc9162_1.CoMETRE.RFC9162_SHA256.root(leaves); | ||
const signed_root = yield signer.sign({ | ||
protectedHeader: { | ||
alg: signer.alg, | ||
kid: log_id + | ||
'/' + | ||
`${prefix}:${tree_alg.toLowerCase()}:${leaf_index}:${rfc9162_1.RFC9162.binToHex(leaf)}`, | ||
alg, | ||
kid | ||
}, | ||
@@ -41,0 +36,0 @@ payload: new_root, |
import { RequestInclusionProof } from '../types'; | ||
export declare const sign_inclusion_proof: ({ log_id, leaf_index, leaves, signer, }: RequestInclusionProof) => Promise<Uint8Array>; | ||
export declare const sign_inclusion_proof: ({ kid, alg, leaf_index, leaves, signer, }: RequestInclusionProof) => Promise<Uint8Array>; |
@@ -20,14 +20,9 @@ "use strict"; | ||
const detachPayload_1 = __importDefault(require("../detachPayload")); | ||
const { tree_alg } = rfc9162_1.CoMETRE.RFC9162_SHA256; | ||
const sign_inclusion_proof = ({ log_id, leaf_index, leaves, signer, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const sign_inclusion_proof = ({ kid, alg, leaf_index, leaves, signer, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const root = rfc9162_1.CoMETRE.RFC9162_SHA256.root(leaves); | ||
const inclusion_proof = rfc9162_1.CoMETRE.RFC9162_SHA256.inclusion_proof(leaf_index, leaves); | ||
const prefix = `urn:ietf:params:trans:inclusion`; | ||
const leaf = leaves[leaf_index]; | ||
const signed_root = yield signer.sign({ | ||
protectedHeader: { | ||
alg: signer.alg, | ||
kid: log_id + | ||
'/' + | ||
`${prefix}:${tree_alg.toLowerCase()}:${leaf_index}:${rfc9162_1.RFC9162.binToHex(leaf)}`, | ||
alg, | ||
kid, | ||
}, | ||
@@ -34,0 +29,0 @@ payload: root, |
import { RequestSignedMerkleRoot } from '../types'; | ||
export declare const sign_root: ({ leaves, signer, }: RequestSignedMerkleRoot) => Promise<Uint8Array>; | ||
export declare const sign_root: ({ alg, kid, leaves, signer, }: RequestSignedMerkleRoot) => Promise<Uint8Array>; |
@@ -14,3 +14,3 @@ "use strict"; | ||
const rfc9162_1 = require("@transmute/rfc9162"); | ||
const sign_root = ({ leaves, signer, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const sign_root = ({ alg, kid, leaves, signer, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const root = rfc9162_1.CoMETRE.RFC9162_SHA256.root(leaves); | ||
@@ -21,3 +21,3 @@ if (!signer) { | ||
const signed_root = yield signer.sign({ | ||
protectedHeader: { alg: signer.alg }, | ||
protectedHeader: { alg, kid }, | ||
payload: root, | ||
@@ -24,0 +24,0 @@ }); |
import { CoseSigner } from './CoseSigner'; | ||
export type RequestConsistencyProof = { | ||
log_id: string; | ||
kid: string; | ||
alg: string; | ||
signed_inclusion_proof: Uint8Array; | ||
@@ -5,0 +6,0 @@ leaves: Uint8Array[]; |
import { CoseSigner } from './CoseSigner'; | ||
export type RequestInclusionProof = { | ||
log_id: string; | ||
kid: string; | ||
alg: string; | ||
leaf_index: number; | ||
@@ -5,0 +6,0 @@ leaves: Uint8Array[]; |
import { CoseSigner } from './CoseSigner'; | ||
export type RequestSignedMerkleRoot = { | ||
alg: string; | ||
kid: string; | ||
leaves: Uint8Array[]; | ||
signer?: CoseSigner; | ||
}; |
{ | ||
"name": "@transmute/cose", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "COSE and related work.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -1,2 +0,2 @@ | ||
import { RFC9162, CoMETRE } from '@transmute/rfc9162' | ||
import { CoMETRE } from '@transmute/rfc9162' | ||
import unprotectedHeader from '../unprotectedHeader' | ||
@@ -6,5 +6,5 @@ import cbor from '../cbor' | ||
const { tree_alg } = CoMETRE.RFC9162_SHA256 | ||
export const sign_consistency_proof = async ({ | ||
log_id, | ||
kid, | ||
alg, | ||
leaves, | ||
@@ -27,14 +27,7 @@ signed_inclusion_proof, | ||
) | ||
const prefix = `urn:ietf:params:trans:consistency` | ||
const leaf = leaves[leaf_index] | ||
const new_root = CoMETRE.RFC9162_SHA256.root(leaves) | ||
const signed_root = await signer.sign({ | ||
protectedHeader: { | ||
alg: signer.alg, | ||
kid: | ||
log_id + | ||
'/' + | ||
`${prefix}:${tree_alg.toLowerCase()}:${leaf_index}:${RFC9162.binToHex( | ||
leaf, | ||
)}`, | ||
alg, | ||
kid | ||
}, | ||
@@ -41,0 +34,0 @@ payload: new_root, |
@@ -1,2 +0,2 @@ | ||
import { RFC9162, CoMETRE } from '@transmute/rfc9162' | ||
import { CoMETRE } from '@transmute/rfc9162' | ||
import unprotectedHeader from '../unprotectedHeader' | ||
@@ -6,6 +6,5 @@ import cbor from '../cbor' | ||
import detachPayload from '../detachPayload' | ||
const { tree_alg } = CoMETRE.RFC9162_SHA256 | ||
export const sign_inclusion_proof = async ({ | ||
log_id, | ||
kid, | ||
alg, | ||
leaf_index, | ||
@@ -20,13 +19,6 @@ leaves, | ||
) | ||
const prefix = `urn:ietf:params:trans:inclusion` | ||
const leaf = leaves[leaf_index] | ||
const signed_root = await signer.sign({ | ||
protectedHeader: { | ||
alg: signer.alg, | ||
kid: | ||
log_id + | ||
'/' + | ||
`${prefix}:${tree_alg.toLowerCase()}:${leaf_index}:${RFC9162.binToHex( | ||
leaf, | ||
)}`, | ||
alg, | ||
kid, | ||
}, | ||
@@ -33,0 +25,0 @@ payload: root, |
@@ -6,2 +6,3 @@ import { CoMETRE } from '@transmute/rfc9162' | ||
export const sign_root = async ({ | ||
alg, kid, | ||
leaves, | ||
@@ -15,3 +16,3 @@ signer, | ||
const signed_root = await signer.sign({ | ||
protectedHeader: { alg: signer.alg }, | ||
protectedHeader: { alg, kid }, | ||
payload: root, | ||
@@ -18,0 +19,0 @@ }) |
import { CoseSigner } from './CoseSigner' | ||
export type RequestConsistencyProof = { | ||
log_id: string | ||
kid: string | ||
alg: string | ||
signed_inclusion_proof: Uint8Array | ||
@@ -6,0 +7,0 @@ leaves: Uint8Array[] |
import { CoseSigner } from './CoseSigner' | ||
export type RequestInclusionProof = { | ||
log_id: string | ||
kid: string | ||
alg: string | ||
leaf_index: number | ||
@@ -6,0 +7,0 @@ leaves: Uint8Array[] |
import { CoseSigner } from './CoseSigner' | ||
export type RequestSignedMerkleRoot = { | ||
alg: string | ||
kid: string | ||
leaves: Uint8Array[] | ||
signer?: CoseSigner | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69728
1289