Merge pull request #1659 from filecoin-project/asr/hash
Use blake2b, instead of sha256, for ticket creation and verification
This commit is contained in:
commit
c649fbf43b
@ -2,6 +2,7 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"github.com/minio/blake2b-simd"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@ -9,7 +10,6 @@ import (
|
|||||||
|
|
||||||
block "github.com/ipfs/go-block-format"
|
block "github.com/ipfs/go-block-format"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/minio/sha256-simd"
|
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
xerrors "golang.org/x/xerrors"
|
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 := BigFromBytes(h[:]).Int
|
||||||
lhs = lhs.Mul(lhs, totpow.Int)
|
lhs = lhs.Mul(lhs, totpow.Int)
|
||||||
|
@ -2,9 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/minio/blake2b-simd"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -455,7 +455,7 @@ func runSeals(sb *ffiwrapper.Sealer, numSectors int, mid abi.ActorID, sectorSize
|
|||||||
|
|
||||||
addpiece := time.Now()
|
addpiece := time.Now()
|
||||||
|
|
||||||
trand := sha256.Sum256(ticketPreimage)
|
trand := blake2b.Sum256(ticketPreimage)
|
||||||
ticket := abi.SealRandomness(trand[:])
|
ticket := abi.SealRandomness(trand[:])
|
||||||
|
|
||||||
log.Info("Running replication(1)...")
|
log.Info("Running replication(1)...")
|
||||||
|
@ -3,10 +3,10 @@ package seed
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/minio/blake2b-simd"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -78,7 +78,7 @@ func PreSeal(maddr address.Address, pt abi.RegisteredProof, offset abi.SectorNum
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
trand := sha256.Sum256(preimage)
|
trand := blake2b.Sum256(preimage)
|
||||||
ticket := abi.SealRandomness(trand[:])
|
ticket := abi.SealRandomness(trand[:])
|
||||||
|
|
||||||
fmt.Printf("sector-id: %d, piece info: %v\n", sid, pi)
|
fmt.Printf("sector-id: %d, piece info: %v\n", sid, pi)
|
||||||
|
Loading…
Reference in New Issue
Block a user