tagion_hirpc_create_signed_sender

Create a signed hirpc from a document

extern (C)
int
tagion_hirpc_create_signed_sender
(
const char* method
,
const size_t method_len
,
const ubyte* param
,
const size_t param_len
,,
const ubyte* deriver
,
const size_t deriver_len
,
ubyte** out_doc
,
size_t* out_doc_len
)

Parameters

method char*

The name of the method

method_len size_t

The length of the method string

param ubyte*

Optional the document to use as the parameter

param_len size_t

The length of the document parameter

root_net securenet_t*

The root net used to sign the message

deriver ubyte*

Optional deriver key

deriver_len size_t

length of the optional deriver key

out_doc ubyte**

The resulting hirpc as a document

out_doc_len size_t*

The length of the resulting document

Return Value

Type: int

Examples

import tagion.api.hibon;
import tagion.api.document;

ubyte* doc_param_ptr = new ubyte;
size_t doc_param_len;
{
    HiBONT* hibon = new HiBONT;
    int rc = tagion_hibon_create(hibon);
    assert(rc == 0);
    scope(exit) tagion_hibon_free(hibon);
    const char[] key = "a";
    rc = tagion_hibon_add_int32(hibon, &key[0], key.length, 7);
    assert(rc == 0);

    rc = tagion_hibon_get_document(hibon, &doc_param_ptr, &doc_param_len);
    assert(rc == 0);
}

string method = "some_method";

securenet_t net;
{
    const(char)[] passphrase = "ababab";
    const(char)[] pin = "babab";
    ubyte* device_doc_ptr = new ubyte;
    size_t device_doc_len;
    tagion_generate_keypair(&passphrase[0], passphrase.length, null, 0, &net, &pin[0], pin.length, &device_doc_ptr, &device_doc_len);
}


{ // Signed hirpc with root key
    ubyte* result_doc_ptr = new ubyte;
    size_t result_doc_len;
    int rc = tagion_hirpc_create_signed_sender(&method[0], method.length, doc_param_ptr, doc_param_len, &net, null, 0, &result_doc_ptr, &result_doc_len);
    assert(rc == 0);

    const doc = Document(result_doc_ptr[0 .. result_doc_len].idup);
    assert(doc.isInorder);
}

{ // Signed hirpc with a derived key
    ubyte* result_doc_ptr = new ubyte;
    size_t result_doc_len;

    ubyte[] tweak_word = [28,1,0,1];
    int rc = tagion_hirpc_create_signed_sender(&method[0], method.length, doc_param_ptr, doc_param_len, &net, &tweak_word[0], tweak_word.length, &result_doc_ptr, &result_doc_len);
    assert(rc == 0);

    const doc = Document(result_doc_ptr[0 .. result_doc_len].idup);
    assert(doc.isInorder);
}