|
|
@ -3,20 +3,16 @@ package test |
|
|
|
import ( |
|
|
|
"math/rand" |
|
|
|
"sync/atomic" |
|
|
|
"time" |
|
|
|
|
|
|
|
ci "github.com/libp2p/go-libp2p-core/crypto" |
|
|
|
) |
|
|
|
|
|
|
|
var generatedPairs int64 = 0 |
|
|
|
var globalSeed int64 |
|
|
|
|
|
|
|
func RandTestKeyPair(typ, bits int) (ci.PrivKey, ci.PubKey, error) { |
|
|
|
seed := time.Now().UnixNano() |
|
|
|
|
|
|
|
// workaround for low time resolution
|
|
|
|
seed += atomic.AddInt64(&generatedPairs, 1) << 32 |
|
|
|
|
|
|
|
return SeededTestKeyPair(typ, bits, time.Now().UnixNano()) |
|
|
|
seed := atomic.AddInt64(&globalSeed, 1) |
|
|
|
return SeededTestKeyPair(typ, bits, seed) |
|
|
|
} |
|
|
|
|
|
|
|
func SeededTestKeyPair(typ, bits int, seed int64) (ci.PrivKey, ci.PubKey, error) { |
|
|
|