kaspeak-sdk / Identifier
Class: Identifier¶
Defined in: crypto/identifier.ts:29
Identifier
A compact, chain-movable label built from a compressed secp256k1 point.
Concept¶
ID(i) = BasePoint · chainKey^i (mod n) ← “chain-key derivation”
where - BasePoint – any long-term public key; - chainKey – 32-byte scalar shared by sender and receiver; - i ≥ 1 – message index.
Features¶
- Created from hexadecimal string / raw bytes, or derived with
fromChainKey
. next()
/prev()
move the label forward or backward along the chain when the caller knows the same chainKey.verify()
checks a Schnorr signature against this public point.
Note: Without the matching chainKey two identifiers look like independent points and cannot be linked.
Extended by¶
Constructors¶
Constructor¶
protected
new Identifier(hex
,bytes
):Identifier
Defined in: crypto/identifier.ts:34
Parameters¶
hex¶
string
bytes¶
Uint8Array
Returns¶
Identifier
Properties¶
hex¶
readonly
hex:string
Defined in: crypto/identifier.ts:30
Accessors¶
bytes¶
Get Signature¶
get bytes():
Uint8Array
Defined in: crypto/identifier.ts:82
Retrieves a copy of the internal byte array.
Returns¶
Uint8Array
A new Uint8Array
instance containing the bytes.
Methods¶
equals()¶
equals(
other
):boolean
Defined in: crypto/identifier.ts:97
Determines whether this identifier is equal to another by comparing their hexadecimal representations.
Parameters¶
other¶
Identifier
The identifier to compare with this instance.
Returns¶
boolean
True if both identifiers have the same hexadecimal string; otherwise, false.
next()¶
next(
chainKey
,count
):Identifier
Defined in: crypto/identifier.ts:114
Jump forward count
positions in the chain:
ID_(i+count) = ID_i · chainKey^count
Parameters¶
chainKey¶
bigint
Shared chainKey
count¶
How many messages ahead (default = 1).
number
| bigint
Returns¶
Identifier
Next identifier in the sequence.
prev()¶
prev(
chainKey
,count
):Identifier
Defined in: crypto/identifier.ts:129
Jump backward count
positions in the chain:
ID_(i-count) = ID_i · chainKey_inv^count
(section 4, bullet 2).
Parameters¶
chainKey¶
bigint
Shared chainKey
count¶
How many messages back (default = 1).
number
| bigint
Returns¶
Identifier
Previous identifier in the sequence.
verify()¶
verify(
sig
,msg
):Promise
\<boolean
>
Defined in: crypto/identifier.ts:143
Verifies the provided signature against the message using the Schnorr algorithm.
Parameters¶
sig¶
Uint8Array
The signature to verify, represented as a Uint8Array.
msg¶
The message to validate, which can be either a string or a Uint8Array.
string
| Uint8Array
\<ArrayBufferLike
>
Returns¶
Promise
\<boolean
>
A Promise that resolves to a boolean indicating whether the signature is valid.
fromBytes()¶
static
fromBytes(bytes
):Identifier
Defined in: crypto/identifier.ts:49
Build Identifier from identifier bytes (33 bytes).
Parameters¶
bytes¶
Uint8Array
Returns¶
Identifier
fromChainKey()¶
static
fromChainKey(chainKey
,index
,publicKey
):Identifier
Defined in: crypto/identifier.ts:64
Derive ID(i) = PK · chainKey^i (mod n).
Parameters¶
chainKey¶
bigint
Shared chainKey
(bigint).
index¶
Message index ≥ 1.
number
| bigint
publicKey¶
Base public point PK(A).
string
| Uint8Array
\<ArrayBufferLike
> | Point
Returns¶
Identifier
Throws¶
RangeError if index = 0
.
fromHex()¶
static
fromHex(hex
):Identifier
Defined in: crypto/identifier.ts:40
Build Identifier from identifier in hex (33 bytes).
Parameters¶
hex¶
string
Returns¶
Identifier