1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.transactionID = exports.sha512Half = exports.Sha512Half = void 0;
|
4 | const hash_prefixes_1 = require("./hash-prefixes");
|
5 | const types_1 = require("./types");
|
6 | const binary_serializer_1 = require("./serdes/binary-serializer");
|
7 | const sha512_1 = require("@xrplf/isomorphic/sha512");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | class Sha512Half extends binary_serializer_1.BytesList {
|
13 | constructor() {
|
14 | super(...arguments);
|
15 | this.hash = sha512_1.sha512.create();
|
16 | }
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | static put(bytes) {
|
24 | return new Sha512Half().put(bytes);
|
25 | }
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | put(bytes) {
|
33 | this.hash.update(bytes);
|
34 | return this;
|
35 | }
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 | finish256() {
|
42 | return Uint8Array.from(this.hash.digest().slice(0, 32));
|
43 | }
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 | finish() {
|
50 | return new types_1.Hash256(this.finish256());
|
51 | }
|
52 | }
|
53 | exports.Sha512Half = Sha512Half;
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | function sha512Half(...args) {
|
61 | const hash = new Sha512Half();
|
62 | args.forEach((a) => hash.put(a));
|
63 | return hash.finish256();
|
64 | }
|
65 | exports.sha512Half = sha512Half;
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | function transactionID(serialized) {
|
73 | return new types_1.Hash256(sha512Half(hash_prefixes_1.HashPrefix.transactionID, serialized));
|
74 | }
|
75 | exports.transactionID = transactionID;
|
76 |
|
\ | No newline at end of file |