Skip to content

Commit

Permalink
remove VC subject tag field (#1940)
Browse files Browse the repository at this point in the history
  • Loading branch information
kziemianek authored Jul 25, 2023
1 parent 952c2ef commit ef2a58f
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 79 deletions.
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::*;
const VC_A1_SUBJECT_DESCRIPTION: &str =
"The user has verified one identity in Web 2 and one identity in Web 3";
const VC_A1_SUBJECT_TYPE: &str = "Basic Identity Verification";
const VC_A1_SUBJECT_TAG: [&str; 1] = ["Litentry Network"];

pub fn build(req: &AssertionBuildRequest) -> Result<Credential> {
debug!("Assertion A1 build, who: {:?}", account_id_to_string(&req.who));
Expand All @@ -44,11 +43,7 @@ pub fn build(req: &AssertionBuildRequest) -> Result<Credential> {
match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
// add subject info
credential_unsigned.add_subject_info(
VC_A1_SUBJECT_DESCRIPTION,
VC_A1_SUBJECT_TYPE,
VC_A1_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A1_SUBJECT_DESCRIPTION, VC_A1_SUBJECT_TYPE);

// add assertion
let flag = web2_cnt != 0 && web3_cnt != 0;
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use lc_data_providers::{
const VC_A10_SUBJECT_DESCRIPTION: &str =
"The user has been consistently holding at least {x} amount of tokens before 2023 Jan 1st 00:00:00 UTC on the supporting networks";
const VC_A10_SUBJECT_TYPE: &str = "WBTC Holding Assertion";
const VC_A10_SUBJECT_TAG: [&str; 1] = ["Ethereum"];

// WBTC Holder
// TODO:
Expand Down Expand Up @@ -74,11 +73,7 @@ pub fn build(req: &AssertionBuildRequest, min_balance: ParameterString) -> Resul

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A10_SUBJECT_DESCRIPTION,
VC_A10_SUBJECT_TYPE,
VC_A10_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A10_SUBJECT_DESCRIPTION, VC_A10_SUBJECT_TYPE);
credential_unsigned.update_holder(
is_hold,
&q_min_balance,
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use lc_data_providers::{
const VC_A11_SUBJECT_DESCRIPTION: &str =
"The user has been consistently holding at least {x} amount of tokens before 2023 Jan 1st 00:00:00 UTC on the supporting networks";
const VC_A11_SUBJECT_TYPE: &str = "ETH Holding Assertion";
const VC_A11_SUBJECT_TAG: [&str; 1] = ["Ethereum"];

// TODO:
// The currently used achainable api is created by creating a label, so all parameters (including min_balance) are hardcoded into the label, and the following pr will be reconstructed using SysemLabel, so the current parameters are retained, but will be ignored.
Expand Down Expand Up @@ -70,11 +69,7 @@ pub fn build(req: &AssertionBuildRequest, min_balance: ParameterString) -> Resul

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A11_SUBJECT_DESCRIPTION,
VC_A11_SUBJECT_TYPE,
VC_A11_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A11_SUBJECT_DESCRIPTION, VC_A11_SUBJECT_TYPE);
credential_unsigned.update_holder(
is_hold,
&q_min_balance,
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use litentry_primitives::Address32;
const VC_A13_SUBJECT_DESCRIPTION: &str =
"The user has a Polkadot Decoded 2023 Litentry Booth Special Badge";
const VC_A13_SUBJECT_TYPE: &str = "Decoded 2023 Basic Special Badge";
const VC_A13_SUBJECT_TAG: [&str; 2] = ["Polkadot decoded 2023", "Litentry"];

pub fn build<O: EnclaveOnChainOCallApi>(
req: &AssertionBuildRequest,
Expand Down Expand Up @@ -60,11 +59,7 @@ pub fn build<O: EnclaveOnChainOCallApi>(
match Credential::new_default(&Address32::from(who.clone()).into(), &req.shard) {
Ok(mut credential_unsigned) => {
// add subject info
credential_unsigned.add_subject_info(
VC_A13_SUBJECT_DESCRIPTION,
VC_A13_SUBJECT_TYPE,
VC_A13_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A13_SUBJECT_DESCRIPTION, VC_A13_SUBJECT_TYPE);

// add assertion
credential_unsigned.add_assertion_a13();
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use ss58_registry::Ss58AddressFormat;
const VC_A14_SUBJECT_DESCRIPTION: &str =
"The user has participated in any Polkadot on-chain governance events";
const VC_A14_SUBJECT_TYPE: &str = "Polkadot Governance Participation Proof";
const VC_A14_SUBJECT_TAG: [&str; 2] = ["Polkadot", "Governance"];

// mostly copied from https://github.com/hack-ink/substrate-minimal/blob/main/subcryptor/src/lib.rs
// no_std version is used here
Expand Down Expand Up @@ -178,11 +177,7 @@ pub fn build(req: &AssertionBuildRequest) -> Result<Credential> {
match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
// add subject info
credential_unsigned.add_subject_info(
VC_A14_SUBJECT_DESCRIPTION,
VC_A14_SUBJECT_TYPE,
VC_A14_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A14_SUBJECT_DESCRIPTION, VC_A14_SUBJECT_TYPE);

// add assertion
credential_unsigned.add_assertion_a14(value);
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use lc_data_providers::{discord_litentry::DiscordLitentryClient, vec_to_string};
const VC_A2_SUBJECT_DESCRIPTION: &str =
"The user has obtained an ID-Hubber role in a Litentry Discord channel";
const VC_A2_SUBJECT_TYPE: &str = "Discord ID-Hubber Role Verification";
const VC_A2_SUBJECT_TAG: [&str; 1] = ["Discord"];

pub fn build(req: &AssertionBuildRequest, guild_id: ParameterString) -> Result<Credential> {
debug!("Assertion A2 build, who: {:?}", account_id_to_string(&req.who));
Expand Down Expand Up @@ -61,11 +60,7 @@ pub fn build(req: &AssertionBuildRequest, guild_id: ParameterString) -> Result<C

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A2_SUBJECT_DESCRIPTION,
VC_A2_SUBJECT_TYPE,
VC_A2_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A2_SUBJECT_DESCRIPTION, VC_A2_SUBJECT_TYPE);

let value = discord_cnt > 0 && has_joined;
credential_unsigned.add_assertion_a2(value, guild_id_s);
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use lc_data_providers::{discord_litentry::DiscordLitentryClient, vec_to_string};
const VC_A3_SUBJECT_DESCRIPTION: &str =
"The user has commented in a specific Discord channel with a specific role";
const VC_A3_SUBJECT_TYPE: &str = "Discord Member Verification";
const VC_A3_SUBJECT_TAG: [&str; 1] = ["Discord"];

pub fn build(
req: &AssertionBuildRequest,
Expand Down Expand Up @@ -76,11 +75,7 @@ pub fn build(

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A3_SUBJECT_DESCRIPTION,
VC_A3_SUBJECT_TYPE,
VC_A3_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A3_SUBJECT_DESCRIPTION, VC_A3_SUBJECT_TYPE);
credential_unsigned.add_assertion_a3(
has_commented,
guild_id_s,
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ use lc_data_providers::{
const VC_A4_SUBJECT_DESCRIPTION: &str =
"The user has been consistently holding at least {x} amount of tokens before 2023 Jan 1st 00:00:00 UTC on the supporting networks";
const VC_A4_SUBJECT_TYPE: &str = "LIT Holding Assertion";
const VC_A4_SUBJECT_TAG: [&str; 3] = ["Ethereum", "Litmus", "Litentry"];

// TODO:
// The currently used achainable api is created by creating a label, so all parameters (including min_balance) are hardcoded into the label, and the following pr will be reconstructed using SysemLabel, so the current parameters are retained, but will be ignored.
Expand Down Expand Up @@ -149,11 +148,7 @@ pub fn build(req: &AssertionBuildRequest, min_balance: ParameterString) -> Resul

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A4_SUBJECT_DESCRIPTION,
VC_A4_SUBJECT_TYPE,
VC_A4_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A4_SUBJECT_DESCRIPTION, VC_A4_SUBJECT_TYPE);
credential_unsigned.update_holder(
is_hold,
&q_min_balance,
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use lc_data_providers::twitter_official::TwitterOfficialClient;

const VC_A6_SUBJECT_DESCRIPTION: &str = "The range of the user's Twitter follower count";
const VC_A6_SUBJECT_TYPE: &str = "Twitter Follower Amount";
const VC_A6_SUBJECT_TAG: [&str; 1] = ["Twitter"];

/// Following ranges:
///
Expand Down Expand Up @@ -94,11 +93,7 @@ pub fn build(req: &AssertionBuildRequest) -> Result<Credential> {

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A6_SUBJECT_DESCRIPTION,
VC_A6_SUBJECT_TYPE,
VC_A6_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A6_SUBJECT_DESCRIPTION, VC_A6_SUBJECT_TYPE);
credential_unsigned.add_assertion_a6(min, max);

Ok(credential_unsigned)
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/assertion-build/src/a7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use lc_data_providers::{
const VC_A7_SUBJECT_DESCRIPTION: &str =
"The user has been consistently holding at least {x} amount of tokens before 2023 Jan 1st 00:00:00 UTC on the supporting networks";
const VC_A7_SUBJECT_TYPE: &str = "DOT Holding Assertion";
const VC_A7_SUBJECT_TAG: [&str; 1] = ["Polkadot"];

// TODO:
// The currently used achainable api is created by creating a label, so all parameters (including min_balance) are hardcoded into the label, and the following pr will be reconstructed using SysemLabel, so the current parameters are retained, but will be ignored.
Expand Down Expand Up @@ -70,11 +69,7 @@ pub fn build(req: &AssertionBuildRequest, min_balance: ParameterString) -> Resul

match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A7_SUBJECT_DESCRIPTION,
VC_A7_SUBJECT_TYPE,
VC_A7_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A7_SUBJECT_DESCRIPTION, VC_A7_SUBJECT_TYPE);
credential_unsigned.update_holder(
is_hold,
&q_min_balance,
Expand Down
8 changes: 1 addition & 7 deletions tee-worker/litentry/core/assertion-build/src/a8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ use lc_data_providers::achainable::{AchainableClient, AchainableTotalTransaction

const VC_A8_SUBJECT_DESCRIPTION: &str = "The total amount of transaction the user has ever made in each of the available networks (including invalid transactions)";
const VC_A8_SUBJECT_TYPE: &str = "EVM/Substrate Transaction Count on Networks";
const VC_A8_SUBJECT_TAG: [&str; 6] =
["Litentry", "Litmus", "Polkadot", "Kusama", "Ethereum", "Khala"];

pub fn build(req: &AssertionBuildRequest) -> Result<Credential> {
debug!("Assertion A8 build, who: {:?}", account_id_to_string(&req.who),);
Expand All @@ -51,11 +49,7 @@ pub fn build(req: &AssertionBuildRequest) -> Result<Credential> {
let (min, max) = get_total_tx_ranges(total_txs);
match Credential::new_default(&req.who, &req.shard) {
Ok(mut credential_unsigned) => {
credential_unsigned.add_subject_info(
VC_A8_SUBJECT_DESCRIPTION,
VC_A8_SUBJECT_TYPE,
VC_A8_SUBJECT_TAG.to_vec(),
);
credential_unsigned.add_subject_info(VC_A8_SUBJECT_DESCRIPTION, VC_A8_SUBJECT_TYPE);
credential_unsigned.add_assertion_a8(networks, min, max);

Ok(credential_unsigned)
Expand Down
7 changes: 1 addition & 6 deletions tee-worker/litentry/core/credentials/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ pub struct CredentialSubject {
pub description: String,
#[serde(rename = "type")]
pub types: String,
/// (Optional) Some externally provided identifiers
pub tag: Vec<String>,
/// (Optional) Data source definitions for trusted data providers
#[serde(skip_serializing_if = "Option::is_none")]
pub data_source: Option<Vec<DataSource>>,
Expand Down Expand Up @@ -368,12 +366,9 @@ impl Credential {
self.credential_subject.values.push(is_hold);
}

pub fn add_subject_info(&mut self, subject_description: &str, types: &str, tag: Vec<&str>) {
pub fn add_subject_info(&mut self, subject_description: &str, types: &str) {
self.credential_subject.description = subject_description.into();
self.credential_subject.types = types.into();

let tag = tag.iter().map(|s| s.to_string()).collect();
self.credential_subject.tag = tag;
}

pub fn add_assertion_a1(&mut self, value: bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
"id":"",
"description":"",
"type":"",
"tag":[
"IDHub"
],
"assertions":[

],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
"type":{
"type":"string"
},
"tag":{
"type":"array"
},
"assertions":{
"type":"array",
"items":{
Expand Down

0 comments on commit ef2a58f

Please sign in to comment.