-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4fe90f
commit 2ef7042
Showing
248 changed files
with
32,892 additions
and
1,096 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// 'use strict'; | ||
// const ursa = require('ursa') | ||
// const crypto = require('crypto') | ||
// const path = require('path') | ||
// const fs = require('fs') | ||
|
||
// var keyPair = ursa.generatePrivateKey(1024, 65537); | ||
// var privkeypem = keyPair.toPrivatePem(); | ||
// var pubkeypem = keyPair.toPublicPem(); | ||
|
||
// var privkeystr = privkeypem.toString('utf8'); | ||
// var pubkeystr = pubkeypem.toString('utf8'); | ||
|
||
// var name = 'saba' | ||
|
||
// console.log(privkeystr); | ||
// console.log(pubkeystr); | ||
|
||
// var privateKeyObj = ursa.coercePrivateKey(privkeystr) | ||
// console.log("Name :", name) | ||
// var sign = keyPair.hashAndSign('sha256', name, 'utf8', 'base64'); | ||
|
||
// // Create public key object from PEM string | ||
// var pub = ursa.createPublicKey(pubkeypem, 'base64'); | ||
|
||
// // Verify signature - should return true | ||
// const bol =pub.hashAndVerify('sha256',name, sign); | ||
|
||
// console.log(bol); | ||
|
||
var ursa = require('ursa'); | ||
|
||
// Generate RSA private key (public key included) | ||
var keyPair = ursa.generatePrivateKey(); | ||
|
||
// Convert public key to string | ||
var pub = keyPair.toPublicPem('base64'); | ||
var privkeypem = keyPair.toPrivatePem(); | ||
var privStr = privkeypem.toString(); | ||
console.log(privStr) | ||
var buf = new Buffer(privStr) | ||
|
||
var jj =ursa.createPrivateKey(buf) | ||
// Create buffer from text | ||
var data = new Buffer('Hello, world!'); | ||
|
||
// Create MD5 hash and sign with private key | ||
var sig = jj.hashAndSign('md5', data); | ||
|
||
// Elsewhere... | ||
|
||
// Create public key object from PEM string | ||
pub = ursa.createPublicKey(pub, 'base64'); | ||
|
||
// Verify signature - should return true | ||
var rr =pub.hashAndVerify('md5', data, sig); | ||
console.log(rr) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const crypto = require("crypto"); | ||
const path = require('path'); | ||
const fs = require('file-system'); | ||
var mv = require('mv'); | ||
const cookieParser = require('cookie-parser'); | ||
const bodyParser = require('body-parser'); | ||
var multer = require('multer'); | ||
var detect = require('detect-file-type'); | ||
var upload = multer({ dest: './website/property/' }); | ||
var uploadFile = multer({ dest: './website/IntellectualProperty/' }); | ||
|
||
const profileInformation = require('./routers/profileInformation'); | ||
const topPeopleIP = require('./routers/topPeopleIP'); | ||
|
||
|
||
const profileVerify= async function (req, res) { | ||
|
||
if (req.cookies.token === undefined) return {view: 'index',obj:undefined}; | ||
else { | ||
var key = req.cookies.key; | ||
var email = req.cookies.email; | ||
var name = ''; | ||
var profilePic = ''; | ||
// console.log('Profile is loading : ' + email +" "+key); | ||
await profileInformation(email, key).then((result) => { | ||
|
||
var obj = JSON.parse(result); | ||
// console.log(peopleList); | ||
name = obj.name; | ||
console.log('change '+ email+' '+name) | ||
profilePic = obj.newFilePath; | ||
|
||
console.log('Your profile pic retrieve from the blockchain'); | ||
|
||
}).catch((error) => { | ||
console.log('View Profile Failed'); | ||
return {view:'index',obj:undefined} | ||
}); | ||
|
||
await topPeopleIP(email).then((result) => { | ||
console.log('now ready , the list is coming'); | ||
var postObj = JSON.parse(result); | ||
// console.log(postObj); | ||
|
||
var loveObj = postObj; | ||
postObj.sort((a, b) => (a.Record.postCnt < b.Record.postCnt) ? 1 : -1); | ||
var newPostObj = postObj.slice(0, 2); // 7 | ||
|
||
loveObj.sort((a, b) => (a.Record.loveCnt < b.Record.loveCnt) ? 1 : -1); | ||
var newLoveObj = loveObj.slice(0, 3); // 8 | ||
|
||
|
||
return {view:'home', obj:{ | ||
'name': name, | ||
'email': email, | ||
'profilePic': profilePic, | ||
'newPostObj': newPostObj, | ||
'newLoveObj': newLoveObj | ||
} | ||
} | ||
} | ||
).catch((e) => { | ||
console.log('Request Failed'); | ||
return {view:'index',obj:undefined} | ||
}); | ||
} | ||
} | ||
module.exports = profileVerify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { FileSystemWallet, Gateway } = require('fabric-network'); | ||
const path = require('path'); | ||
|
||
const ccpPath = path.resolve(__dirname, '..', '..', '..', 'first-network', 'connection-org1.json'); | ||
|
||
async function main(email, userKey, price) { | ||
try { | ||
|
||
// Create a new file system based wallet for managing identities. | ||
const walletPath = path.join(process.cwd(), 'wallet'); | ||
const wallet = new FileSystemWallet(walletPath); | ||
console.log(`Wallet path(Add Balance of User): ${walletPath}`); | ||
|
||
// Check to see if we've already enrolled the user. | ||
const userExists = await wallet.exists(email); | ||
if (!userExists) { | ||
console.log('An identity for the user '+email+' does not exist in the wallet'); | ||
console.log('Run the registerUser.js application before retrying'); | ||
return; | ||
} | ||
|
||
// Create a new gateway for connecting to our peer node. | ||
const gateway = new Gateway(); | ||
await gateway.connect(ccpPath, { wallet, identity: email, discovery: { enabled: true, asLocalhost: true } }); | ||
|
||
// Get the network (channel) our contract is deployed to. | ||
const network = await gateway.getNetwork('mychannel'); | ||
|
||
// Get the contract from the network. | ||
const contract = network.getContract('fabcar'); | ||
|
||
console.log(email + 'is getting money'); | ||
await contract.submitTransaction('addBalance', userKey, price); | ||
|
||
|
||
console.log('Transaction of adding Balance has been submitted'); | ||
|
||
// Disconnect from the gateway. | ||
await gateway.disconnect(); | ||
|
||
} catch (error) { | ||
console.error(`Failed to submit transaction: ${error}`); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// main(); | ||
module.exports = main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { FileSystemWallet, Gateway } = require('fabric-network'); | ||
const path = require('path'); | ||
|
||
const ccpPath = path.resolve(__dirname, '..', '..', '..', 'first-network', 'connection-org1.json'); | ||
|
||
async function main(ipKey, userKey, name, email, dateTime,prevOwnerKey) { | ||
try { | ||
|
||
// Create a new file system based wallet for managing identities. | ||
const walletPath = path.join(process.cwd(), 'wallet'); | ||
const wallet = new FileSystemWallet(walletPath); | ||
console.log(`Wallet path(change ownership of IP): ${walletPath}`); | ||
|
||
// Check to see if we've already enrolled the user. | ||
const userExists = await wallet.exists(email); | ||
if (!userExists) { | ||
console.log('An identity for the user '+email+' does not exist in the wallet'); | ||
console.log('Run the registerUser.js application before retrying'); | ||
return; | ||
} | ||
|
||
// Create a new gateway for connecting to our peer node. | ||
const gateway = new Gateway(); | ||
await gateway.connect(ccpPath, { wallet, identity: email, discovery: { enabled: true, asLocalhost: true } }); | ||
|
||
// Get the network (channel) our contract is deployed to. | ||
const network = await gateway.getNetwork('mychannel'); | ||
|
||
// Get the contract from the network. | ||
const contract = network.getContract('fabcar'); | ||
|
||
console.log(email + '"s IP is going to blockchain '); | ||
await contract.submitTransaction('changeOwner', ipKey, userKey, name, email, dateTime,prevOwnerKey); | ||
|
||
|
||
console.log('Transaction of IP ownership change has been submitted'); | ||
|
||
// Disconnect from the gateway. | ||
await gateway.disconnect(); | ||
|
||
} catch (error) { | ||
console.error(`Failed to submit transaction: ${error}`); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// main(); | ||
module.exports = main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { FileSystemWallet, Gateway } = require('fabric-network'); | ||
const path = require('path'); | ||
|
||
const ccpPath = path.resolve(__dirname, '..', '..', '..', 'first-network', 'connection-org1.json'); | ||
|
||
async function main(email, key, isValid) { | ||
try { | ||
|
||
// Create a new file system based wallet for managing identities. | ||
const walletPath = path.join(process.cwd(), 'wallet'); | ||
const wallet = new FileSystemWallet(walletPath); | ||
console.log(`Wallet path(change validity): ${walletPath}`); | ||
|
||
// Check to see if we've already enrolled the user. | ||
const userExists = await wallet.exists(email); | ||
if (!userExists) { | ||
console.log('An identity for the user '+email+' does not exist in the wallet'); | ||
console.log('Run the registerUser.js application before retrying'); | ||
return; | ||
} | ||
|
||
// Create a new gateway for connecting to our peer node. | ||
const gateway = new Gateway(); | ||
await gateway.connect(ccpPath, { wallet, identity: email, discovery: { enabled: true, asLocalhost: true } }); | ||
|
||
// Get the network (channel) our contract is deployed to. | ||
const network = await gateway.getNetwork('mychannel'); | ||
|
||
// Get the contract from the network. | ||
const contract = network.getContract('fabcar'); | ||
|
||
console.log(email + '"s validity change request is going to blockchain '); | ||
await contract.submitTransaction('changeReq',key, isValid); | ||
|
||
|
||
console.log('Transaction of request validity change has been submitted'); | ||
|
||
// Disconnect from the gateway. | ||
await gateway.disconnect(); | ||
|
||
} catch (error) { | ||
console.error(`Failed to submit transaction: ${error}`); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// main(); | ||
module.exports = main; |
Oops, something went wrong.