JSLib Reference Manual / Exports / SB384
Class: SB384#
Hierarchy#
SB384↳
Channel
Table of contents#
Constructors#
Properties#
Accessors#
Constructors#
constructor#
• new SB384(key?)
Basic (core) capability object in SB.
Note that all the getters below will throw an exception if the corresponding information is not ready.
Like most SB classes, SB384 follows the “ready template” design
pattern: the object is immediately available upon creation,
but isn’t “ready” until it says it’s ready. See Channel Class_
example below. Also see Design Note [4]_.
https://snackabra.io/jslib.html#dn-004-the-ready-pattern
Parameters#
Name |
Type |
Description |
|---|---|---|
|
|
a jwk with which to create identity; if not provided, it will ‘mint’ (generate) them randomly, in other words it will default to creating a new identity (“384”). |
Properties#
ready#
• ready: Promise<SB384>
sb384Ready#
• sb384Ready: Promise<SB384>
Accessors#
_id#
• get _id(): string
Returns#
string
exportable_privateKey#
• get exportable_privateKey(): JsonWebKey
Returns#
JsonWebKey
exportable_pubKey#
• get exportable_pubKey(): JsonWebKey
Returns#
JsonWebKey
hash#
• get hash(): string
Returns a unique identifier for external use, that will be unique for any class or object that uses SB384 as it’s root.
This is deterministic, used to identify users, channels, etc.
The hash is base64 encoding of the SHA-384 hash of the public key, taking the ‘x’ and ‘y’ fields. Note that it is slightly restricted, it only allows [A-Za-z0-9], eg does not allow the ‘_’ or ‘-’ characters. This makes the encoding more practical for end-user interactions like copy-paste. This is accomplished by simply re-hashing until the result is valid. This reduces the entropy of the channel ID by a neglible amount.
Note this is not b62 encoding, which we use for 256-bit entities. This
is still ~384 bits (e.g. x and y fields are each 384 bits, but of course
the underlying total entropy isn’t that, see
NOTE: if you ever need to COMPARE hashes, well short version is that you cannot do so in the general case. You can use sbCrypto.compareHashWithKey() to compare a hash with a key, but you cannot compare two hashes. See the comparison function for more details.
Returns#
string
ownerChannelId#
• get ownerChannelId(): string
Returns#
string
privateKey#
• get privateKey(): CryptoKey
Returns#
CryptoKey
readyFlag#
• get readyFlag(): boolean
Returns#
boolean