Skip to content

Commit

Permalink
🎂 TCKT -> KPass isim değiştir
Browse files Browse the repository at this point in the history
  • Loading branch information
KimlikDAO-bot committed Apr 20, 2024
1 parent 4494ff5 commit e2dab89
Show file tree
Hide file tree
Showing 27 changed files with 165 additions and 145 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "mina/o1js"]
path = mina/o1js
url = https://github.com/o1-labs/o1js
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kimlikdao-js, KimlikDAO projeleri için gerekli olan javascript modüllerinin tu

`crypto`: Kriptografik fonksiyonlar ve kitaplıklar

`did`: KimlikDAO'nun DID ve TCKT tanımları
`did`: KimlikDAO'nun DID ve KPASS tanımları

`ethereum`: Ethereum node'ları ile etkileşim araçları

Expand Down
2 changes: 1 addition & 1 deletion birimler/test/birim/cüzdan/birim.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="cu">
Cüzdan eklendi
<b data-en="bold">kalın</b>
<birim:tckt data-var1="var1value" data-n="100"/>
<birim:kpass data-var1="var1value" data-n="100"/>
</div>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="tc">
TCKT eklendi.
KPASS eklendi.
<div data-set-id="var1">ID should be var1value</div>
<div data-generate="fibonacci"></div>
<div data-generate="add" data-m="101"></div>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions birimler/test/okuyucu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ describe("sayfaOku tests", () => {
const sayfa = sayfaOku("ana/sayfa.html", { dil: "tr", dev: true, kök: "birimler/test/" });
expect(sayfa).toContain("ana/sayfa.css");
expect(sayfa).toContain("Cüzdan eklendi");
expect(sayfa).toContain("TCKT eklendi");
expect(sayfa).toContain("birim/tckt/birim.css");
expect(sayfa).toContain("KPASS eklendi");
expect(sayfa).toContain("birim/kpass/birim.css");

expect(sayfa).toContain("<b>kalın</b>");
expect(sayfa).not.toContain("bold");
Expand Down
4 changes: 2 additions & 2 deletions cloudflare/test/pageWorker.compiled-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const PageWorker = create("https://kimlikdao.org/", {
"?en": "ana-en.html",
"al": "al-tr.html",
"mint": "al-en.html",
"tcktm": "tcktm-tr.html",
"my-tckt": "tcktm-en.html",
"kpassim": "kpassim-tr.html",
"kpass": "kpassim-en.html",
"oyla": "oyla-tr.html",
"vote": "oyla-en.html",
"iptal": "iptal-tr.html",
Expand Down
4 changes: 2 additions & 2 deletions crypto/test/sha3.compiled-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const testKeccak256 = () => {
);

assertEq(
keccak256("TCKT"),
"cad65853fd3e826d6deb3c81411fb138906a27c444b8fe3dffc33ec38b1f3375"
keccak256("KPASS"),
"9f448b217834c1795fa1012375379ddfe66572d54ef164e1262b3887de01e08f"
);

assertEq(
Expand Down
2 changes: 0 additions & 2 deletions did/TCKTVerisi.d.js → did/KPassData.d.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* TCKT için ek `did.Section` tanımları.
*
* @author KimlikDAO
* @externs
*/
Expand Down
53 changes: 26 additions & 27 deletions did/TCKTVerisi.js → did/KPassData.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/**
* @fileoverview TCKT'nin blokzincir dışı saklanan verisini yönetme birimi.
*
* @author KimlikDAO
*/

import { ChainId } from "../crosschain/chains";
import TCKT from "../ethereum/TCKTLite";
import KPASS from "../ethereum/KPASSLite";
import dom from "../util/dom";
import { hex } from "../util/çevir";
import { SectionGroup } from "./decryptedSections";
Expand All @@ -17,15 +15,16 @@ import { SectionGroup } from "./decryptedSections";
const KIMLIKDAO_URL = "https://kimlikdao.org";

/** @const {string} */
const Ä°mzaÄ°steÄŸiTR = `TCKT EriÅŸim Ä°steÄŸi:
const SignPromptTR = `KimlikDAO Pass EriÅŸim Ä°steÄŸi:
-------------------------------------------------
()Bu mesajı imzaladığınızda, bağlı uygulama TCKT’nizin
()Bu mesajı imzaladığınızda, bağlı uygulama KimlikDAO Pass’inizin
{}
bölüm<>ne erişebilecek. Bu mesajı sadece bu bilgileri paylaşmak istiyorsanız imzalayın.\n\n\n`
bölüm<>ne erişebilecek. Bu mesajı sadece bu bilgileri paylaşmak istiyorsanız imzalayın.\n\n\n`;

/** @const {string} */
const Ä°mzaÄ°steÄŸiEN = `KimlikDAO Pass Access Request:
const SignPromptEN = `KimlikDAO Pass Access Request:
-------------------------------------------------
()When you sign this message, the connected app will have access to
Expand All @@ -39,13 +38,13 @@ section<> of your KimlikDAO Pass. Only sign this message if you would like to sh
* @param {string=} giriÅŸEn
* @return {string}
*/
const imzaMetni = (bölümler, girişTr, girişEn) => {
const signPrompt = (bölümler, girişTr, girişEn) => {
/** @const {string} */
const tr = Ä°mzaÄ°steÄŸiTR
const tr = SignPromptTR
.replace("()", giriÅŸTr || "")
.replace("<>", bölümler.length == 1 ? "ü" : "leri");
/** @const {string} */
const en = Ä°mzaÄ°steÄŸiEN
const en = SignPromptEN
.replace("()", giriÅŸEn || "")
.replace("<>", bölümler.length == 1 ? "" : "s");
return (dom.TR ? tr + en : en + tr)
Expand All @@ -59,41 +58,41 @@ const imzaMetni = (bölümler, girişTr, girişEn) => {
* @param {string=} giriÅŸEn
* @return {!SectionGroup}
*/
const bölüm = (bölümler, ağ, girişTr, girişEn) => /** @type {!SectionGroup} */({
const section = (bölümler, ağ, girişTr, girişEn) => /** @type {!SectionGroup} */({
sectionNames: bölümler,
userPrompt: imzaMetni(bölümler, girişTr, girişEn)
+ "Nonce: " + hex(/** @type {!Uint8Array} */(crypto.getRandomValues(new Uint8Array(8))))
+ "\nChainId: " + aÄŸ
+ "\nNFT: " + TCKT.getAddress(aÄŸ)
+ "\nNFT: " + KPASS.getAddress(aÄŸ)
});

/**
* @param {ChainId} aÄŸ
* @param {ChainId} chainId
* @return {{
* metadata: !eth.ERC721Metadata,
* bölümler: !Array<SectionGroup>
* sections: !Array<SectionGroup>
* }}
*/
const metadataVeBölümler = (ağ) => ({
const metadataAndSections = (chainId) => ({
metadata: /** @type {!eth.ERC721Metadata} */({
name: "TCKT",
description: "KimlikDAO Kimlik Tokeni",
image: KIMLIKDAO_URL + "/TCKT.svg",
name: "KPASS",
description: "KimlikDAO Pass",
image: KIMLIKDAO_URL + "/KPASS.svg",
external_url: KIMLIKDAO_URL,
}),
bölümler: [
bölüm(["personInfo", "contactInfo", "addressInfo", "kütükBilgileri"], ağ),
bölüm(["contactInfo", "humanID"], ağ),
bölüm(["humanID"], ağ),
bölüm(["exposureReport"], ağ,
sections: [
section(["personInfo", "contactInfo", "addressInfo", "kütükBilgileri"], ağ),
section(["contactInfo", "humanID"], aÄŸ),
section(["humanID"], aÄŸ),
section(["exposureReport"], aÄŸ,
"https://kimlikdao.org adresinde olduğunuzdan emin olun! Bu adreste değilseniz bu metni imzalamayın.\n\n",
"Ensure that you're on https://kimlikdao.org. If not, don't sign this message!\n\n"
)
]
});

/** @const {!Object<string, string>} */
const OnaylamaAnahtarları = {
const VerificationKeys = {
"exposureReport":
"MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAx6RG1FTAvyuNi4Hd5+o6muaVPgF12CN97J50" +
"YHpHkcEfe3zYMnun/OT1o4fkPidoTgh7PbTOiPvsu6yTVenCjV3PCuwUoKniPCjq0sPMCOgQNTAsOjFg" +
Expand All @@ -119,7 +118,7 @@ const OnaylamaAnahtarları = {
};

export {
OnaylamaAnahtarları,
imzaMetni,
metadataVeBölümler
VerificationKeys,
metadataAndSections,
signPrompt
};
2 changes: 1 addition & 1 deletion did/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const commit = (ownerAddress, commitmentR) => {
/**
* Returns the list of unique signers of an `did.Section`.
*
* Note these signers still need to be validated against the `TCKTSigners`
* Note these signers still need to be validated against the `KimlikDAOPassSigners`
* contract.
*
* @param {string} sectionName
Expand Down
44 changes: 22 additions & 22 deletions did/test/decryptedSections.compiled-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const testCombineMultiple = () => {
const commitmentAnon = commit(ownerAddress, commitmentAnonR);

/** @const {!did.DecryptedSections} */
const tckt = {
const kpass = {
"humanID": /** @type {!did.HumanID} */({
id: "9e10e195f5c4fb987af3077fe241ff7108d39ed7a3b2908da6a37778ad75ee39",
}),
Expand All @@ -96,17 +96,17 @@ const testCombineMultiple = () => {
};

/** @const {!Array<did.DecryptedSections>} */
const tckts = Array(5);
const kpasses = Array(5);

for (let i = 0; i < tckts.length; ++i) {
tckts[i] = /** @type {!did.DecryptedSections} */(structuredClone(tckt));
sign(tckts[i], commitment, commitmentAnon, 1337, BigInt(i + 10));
for (let i = 0; i < kpasses.length; ++i) {
kpasses[i] = /** @type {!did.DecryptedSections} */(structuredClone(kpass));
sign(kpasses[i], commitment, commitmentAnon, 1337, BigInt(i + 10));
}

/** @const {!did.DecryptedSections} */
const combined = combineMultiple(tckts, commitmentR, commitmentAnonR, 5);
const combined = combineMultiple(kpasses, commitmentR, commitmentAnonR, 5);

assertEq(Object.keys(combined).length, Object.keys(tckt).length);
assertEq(Object.keys(combined).length, Object.keys(kpass).length);

assertEq(combined["humanID"].secp256k1.length, 5);
assertEq(combined["personInfo"].secp256k1.length, 5);
Expand Down Expand Up @@ -144,7 +144,7 @@ const testCombineMultipleConflicting = () => {
const commitmentAnon = commit(ownerAddress, commitmentAnonR);

/** @const {!did.DecryptedSections} */
const tckt1 = {
const kpass1 = {
"humanID": /** @type {!did.HumanID} */({
id: "9e10e195f5c4fb987af3077fe241ff7108d39ed7a3b2908da6a37778ad75ee39",
}),
Expand All @@ -155,7 +155,7 @@ const testCombineMultipleConflicting = () => {
};

/** @const {!did.DecryptedSections} */
const tckt2 = {
const kpass2 = {
"humanID": /** @type {!did.HumanID} */({
id: "793ae065c561c060048762a8a9112f0645574f76a9179169cf446147564ff373",
}),
Expand All @@ -166,16 +166,16 @@ const testCombineMultipleConflicting = () => {
};

/** @const {!Array<did.DecryptedSections>} */
const tckts = Array(5);
const kpasses = Array(5);

for (let i = 0; i < tckts.length; ++i) {
tckts[i] = /** @type {!did.DecryptedSections} */(i < 2
? structuredClone(tckt1) : structuredClone(tckt2));
sign(tckts[i], commitment, commitmentAnon, 1337, BigInt(i + 10));
for (let i = 0; i < kpasses.length; ++i) {
kpasses[i] = /** @type {!did.DecryptedSections} */(i < 2
? structuredClone(kpass1) : structuredClone(kpass2));
sign(kpasses[i], commitment, commitmentAnon, 1337, BigInt(i + 10));
}

/** @const {!did.DecryptedSections} */
const combined = combineMultiple(tckts, commitmentR, commitmentAnonR, 3);
const combined = combineMultiple(kpasses, commitmentR, commitmentAnonR, 3);
assertEq(combined["personInfo"].secp256k1.length, 5);
assertEq(combined["humanID"].secp256k1.length, 3);

Expand Down Expand Up @@ -206,7 +206,7 @@ const testCombineMultipleInsufficient = () => {
const commitmentAnon = commit(ownerAddress, commitmentAnonR);

/** @const {!Array<!did.DecryptedSections>} */
const tckt = [{
const kpass = [{
"humanID": /** @type {!did.HumanID} */({
id: "9e10e195f5c4fb987af3077fe241ff7108d39ed7a3b2908da6a37778ad75ee39",
}),
Expand All @@ -233,16 +233,16 @@ const testCombineMultipleInsufficient = () => {
}];

/** @const {!Array<did.DecryptedSections>} */
const tckts = Array(5);
const kpasses = Array(5);

for (let i = 0; i < tckts.length; ++i) {
tckts[i] = /** @type {!did.DecryptedSections} */(
structuredClone(tckt[i % 3]));
sign(tckts[i], commitment, commitmentAnon, 1337, BigInt(i + 10));
for (let i = 0; i < kpasses.length; ++i) {
kpasses[i] = /** @type {!did.DecryptedSections} */(
structuredClone(kpass[i % 3]));
sign(kpasses[i], commitment, commitmentAnon, 1337, BigInt(i + 10));
}

/** @const {!did.DecryptedSections} */
const combined = combineMultiple(tckts, commitmentR, commitmentAnonR, 3);
const combined = combineMultiple(kpasses, commitmentR, commitmentAnonR, 3);
assertEq(combined["personInfo"].secp256k1.length, 5);
assertEq(Object.keys(combined).length, 1);

Expand Down
10 changes: 5 additions & 5 deletions ethereum/TCKTLite.js → ethereum/KPASSLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { ChainId } from "../crosschain/chains";
import { address, callMethod, isNonzero } from "./provider";

/** @const {!Array<string>} */
const TCKT_ADDRS = [
const KPASS_ADDRS = [
"0xcCc0a9b023177549fcf26c947edb5bfD9B230cCc", // All EVM chains except zkSync Era.
"0xcCc053d81e3B85Eac133a5333be4D7cBDd120cCc", // zkSync Era
];

/**
* @param {ChainId} chainId
* @return {string} TCKT contract address
* @return {string} KPASS contract address
*/
const getAddress = (chainId) => TCKT_ADDRS[+(chainId == ChainId.x144)];
const getAddress = (chainId) => KPASS_ADDRS[+(chainId == ChainId.x144)];

/**
* @param {!eth.Provider} provider
Expand All @@ -29,10 +29,10 @@ const handleOf = (provider, chainId, addr) => chainId.startsWith("m:")
* @param {string} addr
* @return {!Promise<boolean>}
*/
const hasDID = (provider, chainId, addr) => handleOf(provider, chainId, addr).then(isNonzero);
const hasKPass = (provider, chainId, addr) => handleOf(provider, chainId, addr).then(isNonzero);

export default {
getAddress,
handleOf,
hasDID,
hasKPass,
};
Loading

0 comments on commit e2dab89

Please sign in to comment.