Skip to content
Snippets Groups Projects
Commit 3fa199f4 authored by Richer Maximilien's avatar Richer Maximilien
Browse files

Squared sequency generation

parent 66c4467d
No related branches found
No related tags found
1 merge request!36189 sign sequence generation
package contract
import (
"dfss/dfssp/entities"
)
// GenerateSignSequence for the contract signature
//
// The generated sequence is an array of integers refering to the User array.
func GenerateSignSequence(users []entities.User) []int {
return squaredSignEngine(len(users))
}
// squaredSignEngine is a basic ^2 engine for sequence generation
func squaredSignEngine(n int) []int {
sequence := make([]int, n*n)
for i := 0; i < n; i++ {
for k := 0; k < n; k++ {
sequence[i*n+k] = k
}
}
return sequence
}
// squaredSignEngineSlice is the same as the above with slicing
func squaredSignEngineSlice(n int) []int {
baseSequence := make([]int, n)
// populate base slice
for i := 0; i < n; i++ {
baseSequence[i] = i
}
sequence := make([]int, 0, n*n)
// append n-1 time the slice to itself
for i := 0; i < n; i++ {
sequence = append(sequence, baseSequence...)
}
return sequence
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment