functional simple api

This commit is contained in:
2024-08-23 16:39:20 -05:00
parent f9354196dd
commit ae4f12c159
18 changed files with 234 additions and 216 deletions

View File

@@ -4,7 +4,7 @@ import (
"crypto/sha256"
"errors"
"fmt"
"go-nkode/core/model"
m "go-nkode/core/model"
"go-nkode/util"
"golang.org/x/crypto/bcrypt"
)
@@ -18,7 +18,7 @@ type UserCipherKeys struct {
MaxNKodeLen int
}
func NewUserCipherKeys(keypadSize model.KeypadSize, setVals []uint64, maxNKodeLen int) (*UserCipherKeys, error) {
func NewUserCipherKeys(keypadSize m.KeypadSize, setVals []uint64, maxNKodeLen int) (*UserCipherKeys, error) {
if len(setVals) != keypadSize.AttrsPerKey {
return nil, errors.New(fmt.Sprintf("setVals len != attrsPerKey, %d, %d", len(setVals), keypadSize.AttrsPerKey))
}
@@ -165,7 +165,7 @@ func (u *UserCipherKeys) DecipherMask(mask string, setVals []uint64, passcodeLen
return passcodeSet, nil
}
func (u *UserCipherKeys) EncipherNKode(passcodeAttrIdx []int, customerAttrs CustomerAttributes) (*model.EncipheredNKode, error) {
func (u *UserCipherKeys) EncipherNKode(passcodeAttrIdx []int, customerAttrs CustomerAttributes) (*m.EncipheredNKode, error) {
code, err := u.EncipherSaltHashCode(passcodeAttrIdx, customerAttrs)
if err != nil {
return nil, err
@@ -180,7 +180,7 @@ func (u *UserCipherKeys) EncipherNKode(passcodeAttrIdx []int, customerAttrs Cust
}
}
mask, err := u.EncipherMask(passcodeSet, customerAttrs)
encipheredCode := model.EncipheredNKode{
encipheredCode := m.EncipheredNKode{
Code: code,
Mask: mask,
}