Restrict adding primary key of one subject as additional key of another subject #118

Closed
opened 2024-10-17 14:03:15 +00:00 by alexvanin · 2 comments
Owner

Subj.

This test pass and it doesn't seem right to me. To use additional keys in TrueCloudLab/frostfs-node#1436 and TrueCloudLab/frostfs-s3-gw#518 it would be much more convenient to check if key is already used as primary key.

func TestAdditionalKeyFromPrimarySubject(t *testing.T) {
	f := newFrostFSIDInvoker(t)
	invoker := f.OwnerInvoker()

	subjAPrimaryKey, err := keys.NewPrivateKey()
	require.NoError(t, err)

	subjBPrimaryKey, err := keys.NewPrivateKey()
	require.NoError(t, err)
	subjBKeyAddr := subjBPrimaryKey.PublicKey().GetScriptHash()

	// create user A
	invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, defaultNamespace, subjAPrimaryKey.PublicKey().Bytes())

	// create user B
	invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, defaultNamespace, subjBPrimaryKey.PublicKey().Bytes())

	// Add A primary key to B as additional key
	invoker.Invoke(t, stackitem.Null{}, addSubjectKeyMethod, subjBKeyAddr, subjAPrimaryKey.PublicKey().Bytes())
}
Subj. This test **pass** and it doesn't seem right to me. To use additional keys in https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/1436 and https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/issues/518 it would be much more convenient to check if key is already used as primary key. ```go func TestAdditionalKeyFromPrimarySubject(t *testing.T) { f := newFrostFSIDInvoker(t) invoker := f.OwnerInvoker() subjAPrimaryKey, err := keys.NewPrivateKey() require.NoError(t, err) subjBPrimaryKey, err := keys.NewPrivateKey() require.NoError(t, err) subjBKeyAddr := subjBPrimaryKey.PublicKey().GetScriptHash() // create user A invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, defaultNamespace, subjAPrimaryKey.PublicKey().Bytes()) // create user B invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, defaultNamespace, subjBPrimaryKey.PublicKey().Bytes()) // Add A primary key to B as additional key invoker.Invoke(t, stackitem.Null{}, addSubjectKeyMethod, subjBKeyAddr, subjAPrimaryKey.PublicKey().Bytes()) } ```
alexvanin added the
discussion
label 2024-10-17 14:03:15 +00:00
fyrchik added this to the v0.21.0 milestone 2024-10-17 14:17:38 +00:00
fyrchik modified the milestone from v0.21.0 to v0.20.0 2024-10-17 14:17:40 +00:00
fyrchik modified the milestone from v0.20.0 to v0.21.0 2024-10-17 14:18:00 +00:00
Owner

Similar question: do we want to have same secondary key belonging to different subjects?
Does it make sense?

Similar question: do we want to have same _secondary_ key belonging to different subjects? Does it make sense?
Author
Owner

I suggest to modify contract to maintain one-to-one relation between any key and subject. Keep an index of all primary and secondary keys, and check unique values during subject creation and key addition.

I suggest to modify contract to maintain one-to-one relation between any key and subject. Keep an index of all primary and secondary keys, and check unique values during subject creation and key addition.
achuprov was assigned by fyrchik 2024-10-18 07:36:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: TrueCloudLab/frostfs-contract#118
No description provided.