Merge pull request #1659 from filecoin-project/asr/hash

Use blake2b, instead of sha256, for ticket creation and verification
This commit is contained in:
Aayush Rajasekaran 2020-05-02 12:26:39 -04:00 committed by GitHub
commit c649fbf43b
3 changed files with 6 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package types
import (
"bytes"
"github.com/minio/blake2b-simd"
"math/big"
"github.com/filecoin-project/specs-actors/actors/abi"
@ -9,7 +10,6 @@ import (
block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/minio/sha256-simd"
"github.com/multiformats/go-multihash"
xerrors "golang.org/x/xerrors"
@ -195,7 +195,7 @@ func IsTicketWinner(vrfTicket []byte, mypow BigInt, totpow BigInt) bool {
*/
h := sha256.Sum256(vrfTicket)
h := blake2b.Sum256(vrfTicket)
lhs := BigFromBytes(h[:]).Int
lhs = lhs.Mul(lhs, totpow.Int)

View File

@ -2,9 +2,9 @@ package main
import (
"context"
"crypto/sha256"
"encoding/json"
"fmt"
"github.com/minio/blake2b-simd"
"io/ioutil"
"math/big"
"math/rand"
@ -455,7 +455,7 @@ func runSeals(sb *ffiwrapper.Sealer, numSectors int, mid abi.ActorID, sectorSize
addpiece := time.Now()
trand := sha256.Sum256(ticketPreimage)
trand := blake2b.Sum256(ticketPreimage)
ticket := abi.SealRandomness(trand[:])
log.Info("Running replication(1)...")

View File

@ -3,10 +3,10 @@ package seed
import (
"context"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/minio/blake2b-simd"
"io/ioutil"
"os"
"path/filepath"
@ -78,7 +78,7 @@ func PreSeal(maddr address.Address, pt abi.RegisteredProof, offset abi.SectorNum
return nil, nil, err
}
trand := sha256.Sum256(preimage)
trand := blake2b.Sum256(preimage)
ticket := abi.SealRandomness(trand[:])
fmt.Printf("sector-id: %d, piece info: %v\n", sid, pi)