gitmark 0.0.57 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/git-mark-list +57 -41
- package/package.json +1 -1
package/bin/git-mark-list
CHANGED
|
@@ -41,7 +41,45 @@ const options = {
|
|
|
41
41
|
fields: ['hash', 'subject', 'authorDate']
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function addCryptoToCommit(commit) {
|
|
45
|
+
b2 = BigInt('0x' + commit.hash)
|
|
46
|
+
b3 = BigInt.asUintN(256, b1 + b2)
|
|
47
|
+
commit.privkey = b1.toString(16)
|
|
48
|
+
commit.tweakedkey = b3.toString(16)
|
|
49
|
+
// console.log('original private key', b3.toString(16))
|
|
50
|
+
// console.log('tweaked private key', b3.toString(16))
|
|
51
|
+
var keyPair1 = bitcoin.ECPair.fromPrivateKey(
|
|
52
|
+
Buffer.from(b1.toString(16), 'hex'),
|
|
53
|
+
{ network: BITMARK }
|
|
54
|
+
)
|
|
55
|
+
commit.wifkey = keyPair1.toWIF()
|
|
56
|
+
|
|
57
|
+
function buf2hex(buffer) {
|
|
58
|
+
// buffer is an ArrayBuffer
|
|
59
|
+
return [...new Uint8Array(buffer)]
|
|
60
|
+
.map(x => x.toString(16).padStart(2, '0'))
|
|
61
|
+
.join('')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
commit.pubkey = buf2hex(keyPair1.publicKey).substring(2)
|
|
65
|
+
// console.log('private key WIF:', keyPair1.toWIF())
|
|
66
|
+
|
|
67
|
+
var { address } = bitcoin.payments.p2pkh({
|
|
68
|
+
pubkey: keyPair1.publicKey,
|
|
69
|
+
network: BITMARK
|
|
70
|
+
})
|
|
71
|
+
commit.address = address
|
|
72
|
+
// console.log('verify address computed from private key:', address)
|
|
73
|
+
|
|
74
|
+
commit.verify = `https://gitmark.info/${commit.subject.split(/[: ]/)[1]}`
|
|
75
|
+
|
|
76
|
+
return commit
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
44
81
|
function renderCommit(commit, type) {
|
|
82
|
+
if (!commit) return
|
|
45
83
|
if (type === 'nostr') {
|
|
46
84
|
var canon = [0, commit.pubkey, commit.authorDate, 1, [], commit.hash]
|
|
47
85
|
|
|
@@ -131,55 +169,33 @@ if (commits.length === 1) {
|
|
|
131
169
|
process.exit()
|
|
132
170
|
}
|
|
133
171
|
|
|
172
|
+
|
|
173
|
+
|
|
134
174
|
// traverse backwards
|
|
135
175
|
// console.log('Genesis tx need not be verified\n')
|
|
136
176
|
var done = 0
|
|
177
|
+
var gitmarks = []
|
|
137
178
|
for (var i = commits.length - 1; i >= 0; i--) {
|
|
138
|
-
var commit = {}
|
|
139
|
-
commit.subject = commits[i].subject
|
|
140
|
-
|
|
141
|
-
if (commit.subject.match(/^gitmark[: ][A-Fa-f0-9]/)) {
|
|
142
|
-
commit.hash = commits[i + 1].hash
|
|
143
|
-
commit.authorDate = Math.floor(
|
|
144
|
-
new Date(commits[i].authorDate).getTime() / 1000
|
|
145
|
-
)
|
|
146
|
-
// console.log()
|
|
147
|
-
b2 = BigInt('0x' + commit.hash)
|
|
148
|
-
b3 = BigInt.asUintN(256, b1 + b2)
|
|
149
|
-
commit.privkey = b1.toString(16)
|
|
150
|
-
commit.tweakedkey = b3.toString(16)
|
|
151
|
-
// console.log('original private key', b3.toString(16))
|
|
152
|
-
// console.log('tweaked private key', b3.toString(16))
|
|
153
|
-
var keyPair1 = bitcoin.ECPair.fromPrivateKey(
|
|
154
|
-
Buffer.from(b1.toString(16), 'hex'),
|
|
155
|
-
{ network: BITMARK }
|
|
156
|
-
)
|
|
157
|
-
commit.wifkey = keyPair1.toWIF()
|
|
158
|
-
|
|
159
|
-
function buf2hex(buffer) {
|
|
160
|
-
// buffer is an ArrayBuffer
|
|
161
|
-
return [...new Uint8Array(buffer)]
|
|
162
|
-
.map(x => x.toString(16).padStart(2, '0'))
|
|
163
|
-
.join('')
|
|
164
|
-
}
|
|
165
179
|
|
|
166
|
-
|
|
167
|
-
// console.log('private key WIF:', keyPair1.toWIF())
|
|
180
|
+
if (commits[i].subject.match(/^gitmark[: ][A-Fa-f0-9]/)) {
|
|
168
181
|
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
commit.verify = `https://gitmark.info/${commit.subject.split(/[: ]/)[1]}`
|
|
177
|
-
|
|
178
|
-
renderCommit(commit, 'nostr')
|
|
179
|
-
done++
|
|
182
|
+
var commit = {
|
|
183
|
+
hash: commits[i + 1]?.hash,
|
|
184
|
+
subject: commits[i].subject,
|
|
185
|
+
authorDate: Math.floor(new Date(commits[i].authorDate).getTime() / 1000),
|
|
186
|
+
privkey: b1.toString(16)
|
|
187
|
+
}
|
|
188
|
+
commit = addCryptoToCommit(commit)
|
|
180
189
|
// console.log(commit)
|
|
181
|
-
|
|
190
|
+
gitmarks.push(commit)
|
|
191
|
+
|
|
182
192
|
}
|
|
183
193
|
}
|
|
184
194
|
|
|
185
195
|
|
|
196
|
+
gitmarks = gitmarks.reverse()
|
|
197
|
+
var len = data.count || gitmarks.length
|
|
198
|
+
for (var i = 0; i < len; i++) {
|
|
199
|
+
// console.log(gitmarks[i])
|
|
200
|
+
renderCommit(gitmarks[i], 'nostr')
|
|
201
|
+
}
|