Compute an sha512-half over some data
Compute an SHA512
hash over the data pointed to by read_ptr
Write the first half of the hash to write_ptr
C
C
write_ptr
uint32_t
Pointer to a buffer the hash will be written to
write_len
uint32_t
Length of output buffer, should be at least 32.
read_ptr
uint32_t
Pointer to the buffer data will be read from (to compute the hash over)
read_len
uint32_t
Length of input data
int64_t
The number of bytes written, should always be 32.
If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.
TOO_SMALL
- Output buffer isn't large enough
Verify a cryptographic signature
Verify a cryptographic signature
If the public key is prefixed with 0xED
then use ED25519
Otherwise assume SECP256k1
C
C
dread_ptr
uint32_t
Pointer to the signed data
dread_len
uint32_t
Length of the signed data
sread_ptr
uint32_t
Pointer to the signature
sread_len
uint32_t
Length of the signature
kread_ptr
uint32_t
Pointer to the public key
kread_len
uint32_t
Length of the public key
int64_t
0
- validation failed, the signature is invalid.
1
- validation succeeded, the signature is valid.
If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.
Compute a serialized keylet of a given type
📘TipNot every Keylet type is supported by this utility function. If you need another Keylet type you can derive it yourself using util_sha512h and by checking the required fields here. A further Keylet tool may assist you.
Compute a keylet of the specified keylet_type
according to the parameters a
through f
depending on type.
Write the serialized 34 byte keylet into write_ptr
C
C
write_ptr
uint32_t
Pointer to a buffer the serialized keylet will be written to
write_len
uint32_t
Length of output buffer, should be at least 34.
keylet_type
uint32_t
One of the keylet types as defined in hookapi.h
e.g. KEYLET_LINE
for a trustline.
a
uint32_t
See keylet table below
b
uint32_t
See keylet table below
c
uint32_t
See keylet table below
d
uint32_t
See keylet table below
e
uint32_t
See keylet table below
f
uint32_t
See keylet table below
KEYLET_HOOK_STATE
a
points to an Account ID
b
is the length of the Account ID (should be 20)
c
points to a hook state key
d
is the length of the key (should be 32)
e
points to a hook state namespace
f
is the length of the namespace (should be 32)
KEYLET_AMENDMENTS KEYLET_FEES KEYLET_NEGATIVE_UNL KEYLET_EMITTED_DIR
a
, b
, c
, d
, e
, f
must all be zero
KEYLET_SKIP
Either:
a
, b
, c
, d
, e
, f
all zero
Or:
a
is a LedgerIndex
b
is 1
c
, d
, e
, f
must all be zero
KEYLET_LINE
a
points to the High Account ID
b
is the length of the above (should be 20)
c
points to the Low Account ID
d
is the length of the above (should be 20)
e
points to the Currency Code
f
is the length of the above (should be 20)
KEYLET_QUALITY
a
points to a serialized keylet
b
is the length of the above (should be 34)
c
is the high 32 bits of the uint64 to pass
d
is the low 32 bits of the uint64 to pass
e
, f
must all be zero
KEYLET_DEPOSIT_PREAUTH
a
points to an Account ID
b
is the length (should be 20)
c
points to an Account ID
d
is the length (should be 20)
e
, f
must all be zero
KEYLET_UNCHECKED KEYLET_CHILD KEYLET_EMITTED_TXN
a
points to a key.
b
is the length of the key (should be 32.)
c
, d
, e
, f
must both be zero
KEYLET_OWNER_DIR KEYLET_SIGNERS KEYLET_ACCOUNT KEYLET_HOOK
a
points to an Account ID.
b
is the length (should be 20.)
c
, d
, e
, f
must all be zero.
KEYLET_PAGE
a
points to a key.
b
is the length of the key (should be 32.)
c
is the high 32 bits of the uint64 to pass
d
is the low 32 bits of the uint64 to pass
e
, f
must both be zero
KEYLET_OFFER KEYLET_CHECK KEYLET_ESCROW KEYLET_NFT_OFFER
a
points to an Account ID.
b
is the length (should be 20.)
And Either:
c
is a 32bit unsigned integer (sequence)
d
is 0
Or:
c
points to a 32 byte key
d
is the length of the key (32).
In both cases:
e
and f
must be 0.
KEYLET_PAYCHAN
a
points to an Account ID
b
is the length (should be 20)
c
points to an Account ID
d
is the length (should be 20)
And Either:
e
32bit unsigned int to pass
f
is zero
Or:
e
points to a 32 byte key
f
is the length of the key (32)
int64_t
The number of bytes written, should always be 34.
If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.
INVALID_ARGUMENT
- Call didn't comply with the above table.
TOO_SMALL
- Writing buffer was smaller than 34 bytes.
Convert an r-address into a 20 byte Account ID
Read an r-address from the read_ptr
Write a 20 byte Account ID to the write_ptr
C
C
write_ptr
uint32_t
Pointer to a buffer of a suitable size to store the output Account ID. Must be at least 20 bytes.
write_len
uint32_t
Length of the output buffer.
read_ptr
uint32_t
Pointer to the r-address.
read_len
uint32_t
The length of the r-address.
int64_t
The number of bytes written (the length of the output r-address).
If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.
INVALID_ARGUMENT
- read_ptr
pointed at something which wasn't a valid r-address.
TOO_SMALL
- write_len
was not large enough to store produced Account ID. (Should be 20 bytes).
TOO_BIG
- read_len
was longer than an r-address can be.
Convert a 20 byte Account ID to an r-address
Read a 20 byte Account ID from the read_ptr
Write the equivalent r-address for that Account ID to write_ptr
C
C
write_ptr
uint32_t
Pointer to a buffer of a suitable size to store the output r-address. Recommend at least 35 bytes.
write_len
uint32_t
Length of the output buffer.
read_ptr
uint32_t
Pointer to the Account ID.
read_len
uint32_t
The length of the input. Always 20.
int64_t
The number of bytes written (the length of the output r-address).
If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.
INVALID_ARGUMENT
- read_len
was not 20.
TOO_SMALL
- write_len
was not large enough to store produced r-address in.