MCPcopy Create free account
hub / github.com/ElementsProject/elements / copyRawAmt

Function copyRawAmt

src/simplicity/elements/env.c:48–61  ·  view source on GitHub ↗

Initialize a 'confAmount' from an unsigned char array from a 'rawElementsTransaction'. * * Precondition: NULL != amt; * unsigned char rawAmt[rawAmt[0] == 0x01 ? 9 : 33] or rawAmt == NULL */

Source from the content-addressed store, hash-verified

46 * unsigned char rawAmt[rawAmt[0] == 0x01 ? 9 : 33] or rawAmt == NULL
47 */
48static void copyRawAmt(confAmount* amt, const unsigned char* rawAmt) {
49 if (rawAmt) {
50 if (0x01 == rawAmt[0]) {
51 amt->prefix = EXPLICIT;
52 amt->explicit = ReadBE64(&rawAmt[1]);
53 } else {
54 amt->prefix = 0x01 == (0x01 & rawAmt[0]) ? ODD_Y : EVEN_Y;
55 sha256_toMidstate(amt->confidential.s, &rawAmt[1]);
56 }
57 } else {
58 amt->prefix = EXPLICIT;
59 amt->explicit = 0;
60 }
61}
62
63/* Initialize a 'sigInput' from a 'rawElementsInput', copying or hashing the data as needed.
64 *

Callers 2

copyInputFunction · 0.85
copyOutputFunction · 0.85

Calls 2

sha256_toMidstateFunction · 0.85
ReadBE64Function · 0.50

Tested by

no test coverage detected