Added sign encoding/decoding stubs
This commit is contained in:
parent
fc03632e20
commit
c9bc6d2bef
|
@ -5,6 +5,7 @@ function parseBuffer (buffer, base = 10) {
|
|||
}
|
||||
|
||||
const keygenDecoders = [
|
||||
null,
|
||||
// round 1
|
||||
function (value) {
|
||||
const res = {
|
||||
|
@ -80,11 +81,15 @@ const keygenDecoders = [
|
|||
}
|
||||
]
|
||||
|
||||
const signDecoders = []
|
||||
|
||||
module.exports = function (isKeygen, round, value) {
|
||||
value = Buffer.from(value.substr(2), 'hex')
|
||||
if (isKeygen) {
|
||||
return keygenDecoders[parseInt(round[round.length - 1]) - 1](value)
|
||||
}
|
||||
const roundNumber = parseInt(round[round.length - 1])
|
||||
const decoder = (isKeygen ? keygenDecoders : signDecoders)[roundNumber]
|
||||
const decoded = decoder(value)
|
||||
console.log(decoded)
|
||||
return decoded
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ function makeBuffer (value, length, base = 10) {
|
|||
}
|
||||
|
||||
const keygenEncoders = [
|
||||
null,
|
||||
// round 1
|
||||
function (value) {
|
||||
const buffers = []
|
||||
|
@ -59,13 +60,15 @@ const keygenEncoders = [
|
|||
}
|
||||
]
|
||||
|
||||
const signEncoders = []
|
||||
|
||||
module.exports = function (isKeygen, round, value) {
|
||||
const parsedValue = JSON.parse(value)
|
||||
if (isKeygen) {
|
||||
const encoded = keygenEncoders[parseInt(round[round.length - 1]) - 1](parsedValue)
|
||||
console.log(`Raw data: ${value.length} bytes, encoded data: ${encoded.length} bytes`)
|
||||
return encoded
|
||||
}
|
||||
const roundNumber = parseInt(round[round.length - 1])
|
||||
const encoder = (isKeygen ? keygenEncoders : signEncoders)[roundNumber]
|
||||
const encoded = encoder(parsedValue)
|
||||
console.log(`Raw data: ${value.length} bytes, encoded data: ${encoded.length} bytes`)
|
||||
return encoded
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue