[WIP] Security work While on holiday
This commit is contained in:
parent
a81ac4efca
commit
7f0231e3f1
109 changed files with 19694 additions and 5210 deletions
167
wasm/types/mtp_wasm.d.ts
vendored
167
wasm/types/mtp_wasm.d.ts
vendored
|
|
@ -34,12 +34,40 @@ export interface ParsedResponse {
|
|||
[field: string]: unknown;
|
||||
}
|
||||
|
||||
export interface ParsedEncryptedValue {
|
||||
kind: "encrypted";
|
||||
encryptionType: number;
|
||||
purpose: number;
|
||||
recipientCount: number;
|
||||
encoded: Uint8Array;
|
||||
}
|
||||
|
||||
export interface ParsedSignedValue {
|
||||
kind: "signed";
|
||||
signatureType: number;
|
||||
purpose: number;
|
||||
signerId: bigint;
|
||||
value: ParsedDataValue;
|
||||
}
|
||||
|
||||
export type ParsedDataValue =
|
||||
| boolean
|
||||
| number
|
||||
| bigint
|
||||
| string
|
||||
| Uint8Array
|
||||
| ParsedDataValue[]
|
||||
| { [key: string]: ParsedDataValue }
|
||||
| ParsedEncryptedValue
|
||||
| ParsedSignedValue
|
||||
| null;
|
||||
|
||||
export interface ParsedFrame {
|
||||
id?: number;
|
||||
type: string;
|
||||
sender?: bigint;
|
||||
receiver?: bigint;
|
||||
data: Record<string, unknown>;
|
||||
data: ParsedDataValue;
|
||||
raw: Uint8Array;
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +117,13 @@ export class WasmEncapsulated implements DisposableWasmObject {
|
|||
readonly ciphertext: Uint8Array;
|
||||
}
|
||||
|
||||
export class WasmKemKeypair implements DisposableWasmObject {
|
||||
readonly public_key: Uint8Array;
|
||||
readonly secret_key: Uint8Array;
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
|
||||
export class WasmClient implements DisposableWasmObject {
|
||||
constructor(
|
||||
on_state_change: StateChangeCallback,
|
||||
|
|
@ -122,6 +157,7 @@ export class WasmClient implements DisposableWasmObject {
|
|||
unsubscribe(id: number): boolean;
|
||||
static is_supported(): boolean;
|
||||
readonly ping_ms: number | undefined;
|
||||
readonly client_id: bigint;
|
||||
readonly state: ConnectionState;
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +176,7 @@ export class WasmKeyring implements DisposableWasmObject {
|
|||
static from_bytes(bytes: Uint8Array): WasmKeyring;
|
||||
public_key_bundle(): WasmPublicKeyBundle;
|
||||
to_bytes(): Uint8Array;
|
||||
validate_full(): void;
|
||||
}
|
||||
|
||||
export class WasmPublicKeyBundle implements DisposableWasmObject {
|
||||
|
|
@ -147,6 +184,7 @@ export class WasmPublicKeyBundle implements DisposableWasmObject {
|
|||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
static from_bytes(bytes: Uint8Array): WasmPublicKeyBundle;
|
||||
static from_bytes_unvalidated(bytes: Uint8Array): WasmPublicKeyBundle;
|
||||
to_bytes(): Uint8Array;
|
||||
readonly kem_public_key: Uint8Array;
|
||||
readonly sig_cl_public_key: Uint8Array;
|
||||
|
|
@ -162,6 +200,44 @@ export class WasmSubscriptionRouter implements DisposableWasmObject {
|
|||
unsubscribe(message_type: string): boolean;
|
||||
}
|
||||
|
||||
export class WasmVerifiedProtectedMessage implements DisposableWasmObject {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
content(): Uint8Array;
|
||||
created_at(): bigint;
|
||||
final_recipient_id(): bigint;
|
||||
matched_signer_key_index(): number;
|
||||
message_id(): string;
|
||||
message_type(): string;
|
||||
protected_version(): bigint;
|
||||
signer_id(): bigint;
|
||||
}
|
||||
|
||||
export class WasmVerifiedRelayContent implements DisposableWasmObject {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
content(): Uint8Array;
|
||||
final_recipient_id(): bigint;
|
||||
message_type(): string;
|
||||
signer_id(): bigint;
|
||||
}
|
||||
|
||||
export class WasmVerifiedRelayMetadata implements DisposableWasmObject {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
created_at(): bigint;
|
||||
encrypted_content(): Uint8Array;
|
||||
final_recipient_id(): bigint;
|
||||
message_id(): string;
|
||||
metadata(): Uint8Array | null;
|
||||
matched_signer_key_index(): number;
|
||||
relay_version(): bigint;
|
||||
signer_id(): bigint;
|
||||
}
|
||||
|
||||
export function build_ping_frame(
|
||||
client_id: bigint,
|
||||
description: string,
|
||||
|
|
@ -174,10 +250,98 @@ export function build_frame(message_type: string, data: Record<string, unknown>,
|
|||
sender?: bigint | number;
|
||||
receiver?: bigint | number;
|
||||
}): Uint8Array;
|
||||
export function build_frame_with_payload(message_type: string, serialized_payload: Uint8Array, options?: {
|
||||
id?: number;
|
||||
sender?: bigint | number;
|
||||
receiver?: bigint | number;
|
||||
}): Uint8Array;
|
||||
|
||||
export function verify_data_value_with_policy(value: Uint8Array, public_key_bundle: Uint8Array, expected_signer_id: bigint, expected_purpose: number, signature_suite: number): void;
|
||||
export function encrypt_data_value(value: Uint8Array, recipient_public_key_bundle: Uint8Array, purpose: number): Uint8Array;
|
||||
export function encrypt_data_value_for_recipients(value: Uint8Array, recipient_public_key_bundles: Uint8Array | Uint8Array[], purpose: number): Uint8Array;
|
||||
export function decrypt_data_value(value: Uint8Array, keyring: Uint8Array, expected_purpose: number): Uint8Array;
|
||||
export function decrypt_data_value_with_keyrings(value: Uint8Array, keyrings: Uint8Array | Uint8Array[], expected_purpose: number): Uint8Array;
|
||||
export function mtp_relay_metadata_encryption_purpose(): number;
|
||||
export function mtp_relay_content_signature_purpose(): number;
|
||||
export function mtp_relay_content_encryption_purpose(): number;
|
||||
export function mtp_relay_metadata_signature_purpose(): number;
|
||||
export function mtp_pipe_session_signature_purpose(): number;
|
||||
export function mtp_pipe_session_encryption_purpose(): number;
|
||||
export function mtp_protection_signature_suite_ed25519(): number;
|
||||
export function mtp_protection_signature_suite_dual(): number;
|
||||
export function open_relay_content_with_keyrings(
|
||||
metadata: WasmVerifiedRelayMetadata,
|
||||
keyrings: Uint8Array | Uint8Array[],
|
||||
signer_public_key_bundles: Uint8Array | Uint8Array[],
|
||||
expected_final_recipient_id: bigint | number | null,
|
||||
signature_suite: number,
|
||||
): WasmVerifiedRelayContent;
|
||||
export function open_relay_metadata_with_keyrings(
|
||||
frame: Uint8Array,
|
||||
keyrings: Uint8Array | Uint8Array[],
|
||||
expected_signer_id: bigint | number,
|
||||
signer_public_key_bundles: Uint8Array | Uint8Array[],
|
||||
signature_suite: number,
|
||||
): WasmVerifiedRelayMetadata;
|
||||
export function relay_metadata_claimed_signer_id(
|
||||
frame: Uint8Array,
|
||||
keyrings: Uint8Array | Uint8Array[],
|
||||
): bigint;
|
||||
export function forward_encrypted_relay_frame(frame: Uint8Array, next_hop_receiver_id: bigint): Uint8Array;
|
||||
export function sign_data_value_with_keyring(value: Uint8Array, signer_id: bigint, purpose: number, keyring: Uint8Array, signature_suite: number): Uint8Array;
|
||||
export function build_encrypted_relay_frame_with_keyring(
|
||||
message_type: string,
|
||||
data: unknown,
|
||||
signer_id: bigint,
|
||||
final_recipient_id: bigint,
|
||||
next_hop_id: bigint,
|
||||
message_id: string,
|
||||
created_at: bigint,
|
||||
encoded_metadata: Uint8Array | null | undefined,
|
||||
keyring_bytes: Uint8Array,
|
||||
signature_suite: number,
|
||||
metadata_recipient_public_key_bundles: Uint8Array | Uint8Array[],
|
||||
content_recipient_public_key_bundles: Uint8Array | Uint8Array[],
|
||||
): Uint8Array;
|
||||
|
||||
export function build_protected_frame_with_keyring(
|
||||
message_type: string,
|
||||
encoded_content: Uint8Array,
|
||||
signer_id: bigint,
|
||||
final_recipient_id: bigint,
|
||||
message_id: string,
|
||||
created_at: bigint,
|
||||
signature_purpose: number,
|
||||
encryption_purpose: number,
|
||||
keyring_bytes: Uint8Array,
|
||||
signature_suite: number,
|
||||
frame_id: number | null | undefined,
|
||||
expose_sender: boolean,
|
||||
recipient_public_key_bundles: Uint8Array | Uint8Array[],
|
||||
): Uint8Array;
|
||||
|
||||
export function open_protected_with_keyrings(
|
||||
frame: Uint8Array,
|
||||
keyrings: Uint8Array | Uint8Array[],
|
||||
expected_signer_id: bigint | number,
|
||||
signer_public_key_bundles: Uint8Array | Uint8Array[],
|
||||
expected_receiver_id: bigint | number | null,
|
||||
signature_purpose: number,
|
||||
encryption_purpose: number,
|
||||
signature_suite: number,
|
||||
): WasmVerifiedProtectedMessage;
|
||||
|
||||
export function protected_claimed_signer_id(
|
||||
frame: Uint8Array,
|
||||
keyrings: Uint8Array | Uint8Array[],
|
||||
encryption_purpose: number,
|
||||
): bigint;
|
||||
|
||||
export function ed25519_generate(): Ed25519GenerateResult;
|
||||
export function ed25519_verify(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): void;
|
||||
export function format_frame(frame: Uint8Array): string;
|
||||
export function parse_data_value(value: Uint8Array): ParsedDataValue;
|
||||
export function encode_data_value(value: unknown): Uint8Array;
|
||||
export function keyring_from_ed25519(secret_key: Uint8Array, public_key: Uint8Array): Uint8Array;
|
||||
export function keyring_generate(): Uint8Array;
|
||||
export function main(): void;
|
||||
|
|
@ -187,6 +351,7 @@ export function wasm_derive_encryption_key(ikm: Uint8Array, salt: Uint8Array, co
|
|||
export function wasm_hkdf_expand(ikm: Uint8Array, salt: Uint8Array, info: Uint8Array, len: number): Uint8Array;
|
||||
export function wasm_kem_decapsulate(recipient_private_key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
||||
export function wasm_kem_encapsulate(recipient_public_key: Uint8Array): WasmEncapsulated;
|
||||
export function wasm_kem_generate_keypair(): WasmKemKeypair;
|
||||
export function wasm_sha256(data: Uint8Array): Uint8Array;
|
||||
export function wasm_sha256_double(data: Uint8Array): Uint8Array;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue