mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Fix acl derivation
This commit is contained in:
parent
2edd059846
commit
4db7d11f1f
1 changed files with 7 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
package commonspace
|
package commonspace
|
||||||
|
|
||||||
import (
|
import (
|
||||||
aclrecordproto2 "github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
aclrecordproto "github.com/anytypeio/any-sync/commonspace/object/acl/aclrecordproto"
|
||||||
"github.com/anytypeio/any-sync/commonspace/object/keychain"
|
"github.com/anytypeio/any-sync/commonspace/object/keychain"
|
||||||
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
"github.com/anytypeio/any-sync/commonspace/object/tree/objecttree"
|
||||||
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
"github.com/anytypeio/any-sync/commonspace/spacestorage"
|
||||||
|
@ -75,7 +75,7 @@ func storagePayloadForSpaceCreate(payload SpaceCreatePayload) (storagePayload sp
|
||||||
}
|
}
|
||||||
|
|
||||||
// preparing acl
|
// preparing acl
|
||||||
aclRoot := &aclrecordproto2.AclRoot{
|
aclRoot := &aclrecordproto.AclRoot{
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
EncryptionKey: encPubKey,
|
EncryptionKey: encPubKey,
|
||||||
SpaceId: spaceId,
|
SpaceId: spaceId,
|
||||||
|
@ -171,7 +171,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload sp
|
||||||
}
|
}
|
||||||
|
|
||||||
// deriving and encrypting read key
|
// deriving and encrypting read key
|
||||||
readKey, err := aclrecordproto2.AclReadKeyDerive(signPrivKey, encPrivKey)
|
readKey, err := aclrecordproto.AclReadKeyDerive(signPrivKey, encPrivKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -181,17 +181,12 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload sp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
readKeyHash := hasher.Sum64()
|
readKeyHash := hasher.Sum64()
|
||||||
encReadKey, err := payload.EncryptionKey.GetPublic().Encrypt(readKey.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// preparing acl
|
// preparing acl
|
||||||
aclRoot := &aclrecordproto2.AclRoot{
|
aclRoot := &aclrecordproto.AclRoot{
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
EncryptionKey: encPubKey,
|
EncryptionKey: encPubKey,
|
||||||
SpaceId: spaceId,
|
SpaceId: spaceId,
|
||||||
EncryptedReadKey: encReadKey,
|
|
||||||
DerivationScheme: SpaceDerivationScheme,
|
DerivationScheme: SpaceDerivationScheme,
|
||||||
CurrentReadKeyHash: readKeyHash,
|
CurrentReadKeyHash: readKeyHash,
|
||||||
}
|
}
|
||||||
|
@ -221,7 +216,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload sp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalAclRoot(aclRoot *aclrecordproto2.AclRoot, key signingkey.PrivKey) (rawWithId *aclrecordproto2.RawAclRecordWithId, err error) {
|
func marshalAclRoot(aclRoot *aclrecordproto.AclRoot, key signingkey.PrivKey) (rawWithId *aclrecordproto.RawAclRecordWithId, err error) {
|
||||||
marshalledRoot, err := aclRoot.Marshal()
|
marshalledRoot, err := aclRoot.Marshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -230,7 +225,7 @@ func marshalAclRoot(aclRoot *aclrecordproto2.AclRoot, key signingkey.PrivKey) (r
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
raw := &aclrecordproto2.RawAclRecord{
|
raw := &aclrecordproto.RawAclRecord{
|
||||||
Payload: marshalledRoot,
|
Payload: marshalledRoot,
|
||||||
Signature: signature,
|
Signature: signature,
|
||||||
}
|
}
|
||||||
|
@ -242,7 +237,7 @@ func marshalAclRoot(aclRoot *aclrecordproto2.AclRoot, key signingkey.PrivKey) (r
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rawWithId = &aclrecordproto2.RawAclRecordWithId{
|
rawWithId = &aclrecordproto.RawAclRecordWithId{
|
||||||
Payload: marshalledRaw,
|
Payload: marshalledRaw,
|
||||||
Id: aclHeadId,
|
Id: aclHeadId,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue