All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scorex.crypto.hash.CommutativeHash.scala Maven / Gradle / Ivy

There is a newer version: 1.2.0-RC3
Show newest version
package scorex.crypto.hash

import scorex.utils.ByteArray

class CommutativeHash[HashFn <: CryptographicHash](hf: HashFn) extends CryptographicHash {
  override val DigestSize: Int = hf.DigestSize

  override def hash(input: Message): Digest = hf.hash(input)

  def apply(x: Message, y:Message): Digest = hash(x, y)

  def hash(x: Message, y: Message): Digest = if (ByteArray.compare(x, y) > 0) hash(x ++ y) else hash(y ++ x)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy