mirror of
https://github.com/fluencelabs/crypto
synced 2025-04-25 14:52:19 +00:00
Fix hash for ed25119 (#12)
* no hasher for default ed25519 * support interop buffers
This commit is contained in:
parent
1502772f8e
commit
64f12eb609
@ -14,7 +14,7 @@ val scalaV = scalaVersion := "2.12.8"
|
|||||||
|
|
||||||
val commons = Seq(
|
val commons = Seq(
|
||||||
scalaV,
|
scalaV,
|
||||||
version := "0.0.10",
|
version := "0.0.15",
|
||||||
fork in Test := true,
|
fork in Test := true,
|
||||||
parallelExecution in Test := false,
|
parallelExecution in Test := false,
|
||||||
organization := "one.fluence",
|
organization := "one.fluence",
|
||||||
|
@ -24,6 +24,6 @@ import scala.language.higherKinds
|
|||||||
|
|
||||||
object CryptoJsHelpers {
|
object CryptoJsHelpers {
|
||||||
implicit class ByteVectorOp(bv: ByteVector) {
|
implicit class ByteVectorOp(bv: ByteVector) {
|
||||||
def toJsBuffer: Buffer = Buffer.from(bv.toHex, "hex")
|
def toJsBuffer: Buffer = new Buffer(ByteVector(bv.toArray).toHex, "hex")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,8 @@ import cats.data.EitherT
|
|||||||
import fluence.crypto.CryptoError.nonFatalHandling
|
import fluence.crypto.CryptoError.nonFatalHandling
|
||||||
import fluence.crypto.facade.ed25519.Supercop
|
import fluence.crypto.facade.ed25519.Supercop
|
||||||
import fluence.crypto.hash.JsCryptoHasher
|
import fluence.crypto.hash.JsCryptoHasher
|
||||||
import fluence.crypto.{Crypto, CryptoError, KeyPair, CryptoJsHelpers}
|
import fluence.crypto.{Crypto, CryptoError, CryptoJsHelpers, KeyPair}
|
||||||
import fluence.crypto.signature.{SignAlgo, Signature, SignatureChecker, Signer}
|
import fluence.crypto.signature.{SignAlgo, Signature, SignatureChecker, Signer}
|
||||||
import io.scalajs.nodejs.buffer.Buffer
|
|
||||||
import scodec.bits.ByteVector
|
import scodec.bits.ByteVector
|
||||||
|
|
||||||
import scala.language.higherKinds
|
import scala.language.higherKinds
|
||||||
@ -38,7 +37,7 @@ class Ed25519(hasher: Option[Crypto.Hasher[Array[Byte], Array[Byte]]]) {
|
|||||||
hash ← JsCryptoHasher.hash(message, hasher)
|
hash ← JsCryptoHasher.hash(message, hasher)
|
||||||
sign ← nonFatalHandling {
|
sign ← nonFatalHandling {
|
||||||
Supercop.sign(
|
Supercop.sign(
|
||||||
Buffer.from(ByteVector(hash).toHex, "hex"),
|
ByteVector(hash).toJsBuffer,
|
||||||
keyPair.publicKey.value.toJsBuffer,
|
keyPair.publicKey.value.toJsBuffer,
|
||||||
keyPair.secretKey.value.toJsBuffer
|
keyPair.secretKey.value.toJsBuffer
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Fluence Labs Limited
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package fluence.crypto.facade
|
||||||
|
|
||||||
|
import scala.scalajs.js
|
||||||
|
import scala.scalajs.js.annotation.JSGlobal
|
||||||
|
|
||||||
|
@js.native
|
||||||
|
@JSGlobal("Buffer")
|
||||||
|
class Buffer(arr: js.Array[Byte]) extends js.Object {
|
||||||
|
def toString(enc: String): String = js.native
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user