beetlebug▾
/

ztcl::meter verify

Checks the signature of a record.

ztcl::meter verify RECORD PUBLICKEY

Description

Gives 1 when the Ed25519 signature of the signed record RECORD matches the hex public key PUBLICKEY, else 0. A changed record or another key gives 0.

Arguments

ArgumentTypeDefaultDescription
RECORDline of JSONrequiredA record of record -key or record -sign.
PUBLICKEY64 hex digitsrequiredThe public key of the signer.

Returns

1 or 0.

Examples

Each example of this page runs after package require ztcl::json.

% ztcl::meter create v
> set seed [string repeat 0 63]1
> set r [ztcl::meter record v -key $seed]
> set other [ztcl::meter pubkey [string repeat 0 63]2]
> set bad [string map {{"units":} {"units":1}} $r]
> list [ztcl::meter verify $r [ztcl::meter pubkey $seed]] [ztcl::meter verify $r $other] [ztcl::meter verify $bad [ztcl::meter pubkey $seed]]
1 0 0

Errors

% ztcl::meter verify {{}} xyz
a public key is 64 hex digits
-errorcode ZTCL METER KEY

% ztcl::meter verify
wrong # args: should be "ztcl::meter verify record publickey"
-errorcode TCL WRONGARGS

Facts

Capability
meter. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also