Skip to content
Merged
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
File renamed without changes.
2 changes: 1 addition & 1 deletion src/.errors/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/.helpers/getBufferSourceLength.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/CipherMessage/.core/CipherKeyHarness/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
16 changes: 15 additions & 1 deletion src/CipherMessage/.core/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,16 +37,30 @@ type A256CTRKey = JsonWebKey &
key_ops: readonly ('encrypt' | 'decrypt')[]
}

/**
* Algorithm parameters serialized alongside an AES-CTR cipher message.
*/
export type A256CTRParams = {
/** The 96-bit initialization vector used for encryption. */
iv: Uint8Array
}

type A256CTRMessage = {
/** The encrypted payload bytes. */
ciphertext: ArrayBuffer
} & A256CTRParams

/**
* Symmetric AES-CTR-256 JWK used for cipher messaging operations.
*/
export type CipherKey = A256CTRKey

/**
* Serialized parameters required to decrypt a cipher message.
*/
export type CipherParams = A256CTRParams

/**
* Cipher message artifact returned by cipher encryption operations.
*/
export type CipherMessage = A256CTRMessage
2 changes: 1 addition & 1 deletion src/CipherMessage/CipherCluster/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/CipherMessage/deriveCipherKey/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/CipherMessage/generateCipherKey/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/CipherMessage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/DigitalSignature/.core/SignKeyHarness/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/DigitalSignature/.core/VerifyKeyHarness/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
13 changes: 12 additions & 1 deletion src/DigitalSignature/.core/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,15 +50,26 @@ type MLDSA87SignKey = JsonWebKey &
}

type MLDSA87VerifyParams = {
/** The raw ML-DSA-87 public key bytes. */
publicKey: Uint8Array
}

type MLDSA87SignParams = {
/** The raw ML-DSA-87 secret key bytes. */
secretKey: Uint8Array
}

/**
* Public ML-DSA-87 JWK used to verify signatures.
*/
export type VerifyKey = MLDSA87VerifyKey

/**
* Private ML-DSA-87 JWK used to produce signatures.
*/
export type SignKey = MLDSA87SignKey

/**
* Runtime ML-DSA-87 key material used internally by signing and verification harnesses.
*/
export type DigitalSignatureParams = MLDSA87VerifyParams | MLDSA87SignParams
2 changes: 1 addition & 1 deletion src/DigitalSignature/DigitalSignatureCluster/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
18 changes: 1 addition & 17 deletions src/DigitalSignature/deriveDigitalSignatureKeypair/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,22 +60,6 @@ export async function deriveDigitalSignatureKeypair(
key_ops: ['verify'],
})

/* c8 ignore next 6 */
if (!('d' in signKey)) {
throw new CryptosuiteError(
'SIGN_JWK_INVALID',
'deriveDigitalSignatureKeypair: internal sign key invariant failed.'
)
}

/* c8 ignore next 6 */
if (!('x' in verifyKey)) {
throw new CryptosuiteError(
'VERIFY_JWK_INVALID',
'deriveDigitalSignatureKeypair: internal verify key invariant failed.'
)
}

return {
signKey: signKey as SignKey,
verifyKey: verifyKey as VerifyKey,
Expand Down
19 changes: 1 addition & 18 deletions src/DigitalSignature/generateDigitalSignatureKeypair/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,6 @@ limitations under the License.
*/
import { toBase64UrlString } from '@sovereignbase/bytecodec'
import { ml_dsa87 } from '@noble/post-quantum/ml-dsa.js'
import { CryptosuiteError } from '../../.errors/class.js'
import { validateKeyByAlgCode } from '../.core/helpers/validateKeyByAlgCode/index.js'
import type { SignKey, VerifyKey } from '../.core/types/index.js'

Expand Down Expand Up @@ -44,22 +43,6 @@ export async function generateDigitalSignatureKeypair(): Promise<{
key_ops: ['verify'],
})

/* c8 ignore next 6 */
if (!('d' in signKey)) {
throw new CryptosuiteError(
'SIGN_JWK_INVALID',
'generateDigitalSignatureKeypair: internal sign key invariant failed.'
)
}

/* c8 ignore next 6 */
if (!('x' in verifyKey)) {
throw new CryptosuiteError(
'VERIFY_JWK_INVALID',
'generateDigitalSignatureKeypair: internal verify key invariant failed.'
)
}

return {
signKey: signKey as SignKey,
verifyKey: verifyKey as VerifyKey,
Expand Down
2 changes: 1 addition & 1 deletion src/DigitalSignature/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/Identifier/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/KeyAgreement/.core/DecapsulateKeyHarness/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/KeyAgreement/.core/EncapsulateKeyHarness/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/KeyAgreement/.core/helpers/getParamsByAlgCode/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2026 z-base
Copyright 2026 Sovereignbase

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
15 changes: 15 additions & 0 deletions src/KeyAgreement/.core/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,38 @@ type MLKEM1024DecapsulateKey = JsonWebKey &
}

type MLKEM1024KeyOffer = {
/** The encapsulated shared-secret artifact emitted by ML-KEM-1024. */
ciphertext: ArrayBuffer
}

type MLKEM1024EncapsulateParams = {
/** The raw ML-KEM-1024 public key bytes. */
publicKey: Uint8Array
}

type MLKEM1024DecapsulateParams = {
/** The raw ML-KEM-1024 secret key bytes. */
secretKey: Uint8Array
}

/**
* Public ML-KEM-1024 JWK used to encapsulate a shared cipher key.
*/
export type EncapsulateKey = MLKEM1024EncapsulateKey

/**
* Private ML-KEM-1024 JWK used to decapsulate a shared cipher key.
*/
export type DecapsulateKey = MLKEM1024DecapsulateKey

/**
* Encapsulated key agreement artifact exchanged with the counterparty.
*/
export type KeyOffer = MLKEM1024KeyOffer

/**
* Runtime ML-KEM-1024 parameters used internally by key agreement harnesses.
*/
export type KeyAgreementParams =
| MLKEM1024EncapsulateParams
| MLKEM1024DecapsulateParams
23 changes: 2 additions & 21 deletions src/KeyAgreement/deriveKeyAgreementKeypair/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,8 @@ export async function deriveKeyAgreementKeypair(
key_ops: ['deriveKey', 'deriveBits'],
})

/* c8 ignore next 6 */
if (!('x' in encapsulateKey)) {
throw new CryptosuiteError(
'KEY_AGREEMENT_KEY_INVALID',
'deriveKeyAgreementKeypair: internal key validation invariant failed.'
)
}

/* c8 ignore next 6 */
if (!('d' in decapsulateKey)) {
throw new CryptosuiteError(
'KEY_AGREEMENT_KEY_INVALID',
'deriveKeyAgreementKeypair: internal key validation invariant failed.'
)
}

const normalizedEncapsulateKey = encapsulateKey as EncapsulateKey
const normalizedDecapsulateKey = decapsulateKey as DecapsulateKey

return {
encapsulateKey: normalizedEncapsulateKey,
decapsulateKey: normalizedDecapsulateKey,
encapsulateKey: encapsulateKey as EncapsulateKey,
decapsulateKey: decapsulateKey as DecapsulateKey,
}
}
Loading
Loading