github.com/deso-protocol/core@v1.2.9/desohash/sha3m/doc.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package sha3m implements the SHA-3 fixed-output-length hash functions with modifications for DeSo proof-of-work 6 // 7 // Guidance 8 // 9 // Security strengths 10 // 11 // The SHA3-x (x equals 224, 256, 384, or 512) functions have a security 12 // strength against preimage attacks of x bits. Since they only produce "x" 13 // bits of output, their collision-resistance is only "x/2" bits. 14 // 15 // The sponge construction 16 // 17 // A sponge builds a pseudo-random function from a public pseudo-random 18 // permutation, by applying the permutation to a state of "rate + capacity" 19 // bytes, but hiding "capacity" of the bytes. 20 // 21 // A sponge starts out with a zero state. To hash an input using a sponge, up 22 // to "rate" bytes of the input are XORed into the sponge's state. The sponge 23 // is then "full" and the permutation is applied to "empty" it. This process is 24 // repeated until all the input has been "absorbed". The input is then padded. 25 // The digest is "squeezed" from the sponge in the same way, except that output 26 // is copied out instead of input being XORed in. 27 // 28 // A sponge is parameterized by its generic security strength, which is equal 29 // to half its capacity; capacity + rate is equal to the permutation's width. 30 // Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means 31 // that the security strength of a sponge instance is equal to (1600 - bitrate) / 2. 32 // 33 // The SHA-3 functions are "drop-in" replacements for the SHA-2 functions. 34 // They produce output of the same length, with the same security strengths 35 // against all attacks. This means, in particular, that SHA3-256 only has 36 // 128-bit collision resistance, because its output length is 32 bytes. 37 package sha3m // import "github.com/deso-protocol/lib/sha3m"