Class: SdObjectEncoder
identity_wasm.SdObjectEncoder
Transforms a JSON object into an SD-JWT object by substituting selected values with their corresponding disclosure digests.
Note: digests are created using the sha-256 algorithm.
Table of contents
Constructors
Methods
Constructors
constructor
• new SdObjectEncoder(object
)
Creates a new SdObjectEncoder
with sha-256
hash function.
Parameters
Name | Type |
---|---|
object | any |
Methods
toJSON
▸ toJSON(): Object
- Return copy of self without private attributes.
Returns
Object
▸ toJSON(): any
Returns the modified object.
Returns
any
toString
▸ toString(): string
Return stringified version of self.
Returns
string
▸ toString(): string
Returns the modified object as a string.
Returns
string
conceal
▸ conceal(path
, salt?
): Disclosure
Substitutes a value with the digest of its disclosure. If no salt is provided, the disclosure will be created with a random salt value.
path
indicates the pointer to the value that will be concealed using the syntax of
JSON pointer.
For the following object:
{
"id": "did:value",
"claim1": {
"abc": true
},
"claim2": ["val_1", "val_2"]
}
Path "/id" conceals "id": "did:value"
Path "/claim1/abc" conceals "abc": true
Path "/claim2/0" conceals val_1
Errors
InvalidPath
if pointer is invalid.DataTypeMismatch
if existing SD format is invalid.
Parameters
Name | Type |
---|---|
path | string |
salt? | string |
Returns
addSdAlgProperty
▸ addSdAlgProperty(): void
Adds the _sd_alg
property to the top level of the object, with
its value set to "sha-256".
Returns
void
encodeToString
▸ encodeToString(): string
Returns the modified object as a string.
Returns
string
encodeToObject
▸ encodeToObject(): Record
\<string
, any
>
Returns the modified object.
Returns
Record
\<string
, any
>
addDecoys
▸ addDecoys(path
, number_of_decoys
): void
Adds a decoy digest to the specified path. If path is an empty slice, decoys will be added to the top level.
Parameters
Name | Type |
---|---|
path | string |
number_of_decoys | number |
Returns
void