PrivacySalt
Keywords: net.corda.core.contracts.PrivacySalt class
Date: 2023-09-18

net.corda.core.contracts

## Class PrivacySalt

- net.corda.core.utilities.ByteSequence
- - net.corda.core.utilities.OpaqueBytes
  - - net.corda.core.contracts.PrivacySalt

-     public class PrivacySalt
      extends OpaqueBytes

  A privacy salt is required to compute nonces per transaction component in order to ensure that an adversary cannot use brute force techniques and reveal the content of a Merkle-leaf hashed value. Because this salt serves the role of the seed to compute nonces, its size and entropy should be equal to the underlying hash function used for Merkle tree generation, currently `class SecureHash.SHA256`, which has an output of 32 bytes. There are two constructors, one that generates a new 32-bytes random salt, and another that takes a ByteArray input. The latter is required in cases where the salt value needs to be pre-generated (agreed between transacting parties), but it is highlighted that one should always ensure it has sufficient entropy.

  See Also:
    `class SecureHash.SHA256`, ByteArray

- - ### Field Detail

    - #### Companion

          public static net.corda.core.contracts.PrivacySalt.Companion Companion

  - ### Constructor Detail

    - #### PrivacySalt

          public PrivacySalt(@NotNull
                             kotlin.Array[] bytes)

      A privacy salt is required to compute nonces per transaction component in order to ensure that an adversary cannot use brute force techniques and reveal the content of a Merkle-leaf hashed value. Because this salt serves the role of the seed to compute nonces, its size and entropy should be equal to the underlying hash function used for Merkle tree generation, currently `class SecureHash.SHA256`, which has an output of 32 bytes. There are two constructors, one that generates a new 32-bytes random salt, and another that takes a ByteArray input. The latter is required in cases where the salt value needs to be pre-generated (agreed between transacting parties), but it is highlighted that one should always ensure it has sufficient entropy.

      See Also:
        `class SecureHash.SHA256`, ByteArray

    - #### PrivacySalt

          public PrivacySalt(int saltLength)

      Constructs a salt with a randomly-generated saltLength byte value.

    - #### PrivacySalt

          public PrivacySalt()

      Constructs a salt with a randomly-generated 32 byte value.

  - ### Method Detail

    - #### createFor

          @JvmStatic
           @NotNull
          public static PrivacySalt createFor(@NotNull
                                                                   java.lang.String algorithm)