2022-11-04 11:38:32 +11:00
|
|
|
import {
|
2022-11-23 16:25:50 +11:00
|
|
|
DecodedMessage as DecodedMessageV0,
|
2022-11-04 11:38:32 +11:00
|
|
|
proto,
|
2022-12-06 12:49:02 +11:00
|
|
|
} from "@waku/core/lib/message/version_0";
|
2022-12-05 17:07:03 +11:00
|
|
|
import type { IDecodedMessage } from "@waku/interfaces";
|
2022-11-04 11:38:32 +11:00
|
|
|
|
2022-11-04 11:45:15 +11:00
|
|
|
import {
|
|
|
|
|
generatePrivateKey,
|
|
|
|
|
generateSymmetricKey,
|
|
|
|
|
getPublicKey,
|
2022-11-23 16:38:19 +11:00
|
|
|
} from "./crypto/index.js";
|
2022-11-04 11:38:32 +11:00
|
|
|
|
2022-11-23 16:59:15 +11:00
|
|
|
export const OneMillion = BigInt(1_000_000);
|
2022-11-04 11:38:32 +11:00
|
|
|
|
2022-11-04 11:45:15 +11:00
|
|
|
export { generatePrivateKey, generateSymmetricKey, getPublicKey };
|
|
|
|
|
|
2022-12-05 15:54:55 +11:00
|
|
|
export * as ecies from "./ecies.js";
|
|
|
|
|
export * as symmetric from "./symmetric.js";
|
|
|
|
|
|
2022-11-04 11:38:32 +11:00
|
|
|
export const Version = 1;
|
|
|
|
|
|
|
|
|
|
export type Signature = {
|
|
|
|
|
signature: Uint8Array;
|
|
|
|
|
publicKey: Uint8Array | undefined;
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-23 16:25:50 +11:00
|
|
|
export class DecodedMessage
|
|
|
|
|
extends DecodedMessageV0
|
|
|
|
|
implements IDecodedMessage
|
|
|
|
|
{
|
2022-11-04 11:38:32 +11:00
|
|
|
private readonly _decodedPayload: Uint8Array;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
proto: proto.WakuMessage,
|
|
|
|
|
decodedPayload: Uint8Array,
|
|
|
|
|
public signature?: Uint8Array,
|
|
|
|
|
public signaturePublicKey?: Uint8Array
|
|
|
|
|
) {
|
|
|
|
|
super(proto);
|
|
|
|
|
this._decodedPayload = decodedPayload;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get payload(): Uint8Array {
|
|
|
|
|
return this._decodedPayload;
|
|
|
|
|
}
|
|
|
|
|
}
|